Multiple assignment and tuple unpacking improve Python code readability

This page summarizes the projects mentioned and recommended in the original post on news.ycombinator.com

Our great sponsors
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • WorkOS - The modern identity platform for B2B SaaS
  • SaaSHub - Software Alternatives and Reviews
  • julia

    The Julia Programming Language

  • that's all cool and fine, but can you unpack named tuple or struct (data class)? In Julia one of my favorite quality of life improvement in the 1.7: https://github.com/JuliaLang/julia/pull/39285

    Example:

        julia> X = (this = 3, that = 5)

  • UnPack.jl

    `@pack!` and `@unpack` macros

  • That’s cool that this is in Julia Base! Do you know how it compares to Unpack.jl? I love this feature because you can do partial unpacking by name

    https://github.com/mauro3/Unpack.jl

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
  • cant

    A programming argot

  • Thank you!

    I dislike style nazis too, e.g. carping when Peter Norvig's code won't pass PEP 8.

    I'm just leery of the expected cost in this kind of case. It can go on working for years until some new complication or some change in the ecosystem makes it suddenly create a really weird problem. Or when you want to try moving to a fancy new Python implementation, you find you have this friction. Matter of judgement where some chance of such messes is paid for by what it can do for you. (Of course when it's less "load bearing" the balance shifts.) With https://coverage.readthedocs.io/en/stable/ for example, it used bytecode hacks to do something you couldn't do otherwise, and that's unlikely to mess you up.

    I have had old C programs go crazy years later in a really hard to debug way because newer compilers may interpret your code like your ex-wife's divorce lawyer (as Kragen put it, iirc). Back in the day a lot of us thought we had a different kind of relationship with C compilers, and it'd be fine to code to that informal social contract. (Just a loose analogy.)

    I'm piddling away at https://github.com/darius/cant these days. (Some of the motivation was feeling too confined by Python, actually.) No Wasm, but I'm happy it exists! I tried to make a system like it 20 years ago (Idel) and gave up too soon.

  • schism

    A self-hosting Scheme to WebAssembly compiler (by schism-lang)

  • I love E! Or at least the problems it is trying to solve. As you know Wasm also has a capabilities model. And it is fairly trivial to persist the Wasm heap, it just an array of bytes. I think Wasm aligns nicely.

    Chez is a great Scheme, but it doesn't have a Wasm backend. I find https://github.com/schism-lang/schism very interesting.

    As for C programs going crazy, well yeah. I did a thing where I would copy of the body of functions around in memory, it worked on some version of Linux and GCC, but only by accident. I would be much less comfortable doing this kind of circuit bending than modifying Python stack frames. If I were to achieve a similar goal in the future, I'd use TCC, generate C code and compile directly into memory.

    Framehacks aren't going to do the same thing, and one should have tests for it regardless. Framehacks get you tail calls, stack scope and a bunch of other nice properties.

    Happy Hacking!

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts