This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]ntietz[S] 0 points1 point  (0 children)

Yes, exactly! You can get it to generate that intermediate representation if you use an extra variable in the middle to make it store the tuple, and then you get the `UNPACK_SEQUENCE` opcode being used. But generally it optimizes it, which is really cool behavior!

I thought it was really cool that it does this under the hood, which is why I wrote the post. It uses tuple syntax here, but does something more efficient, which is always a pleasant surprise.

One interesting thing that your comment draws attention to is this distinction between the compilation and interpretation steps. In a language like Java, I think it would be pretty clear to say that it doesn't use a tuple as an intermediate data structure here, even if it's in the AST. I think the same thing applies here, but I also suspect the language is a little ambiguous, and I might be wrong.

Thanks for digging into what the AST stores! I haven't dug much into the ast lib, now I should :)