Closed lpereira closed 1 year ago
Good question. I noticed that LIST_APPEND
also expects the arguments in reverse order. Maybe related?
Both list and tuples are evaluated left-to-right (as is all Python code) and are in the same order.
>>> (print(1), print(2))
1
2
(None, None)
>>> [print(1), print(2)]
1
2
[None, None]
BUILD_LIST
could be improved in a similar way to BUILD_TUPLE
by moving the items en masse.
I misunderstood the code. Will send a PR making the change to BUILD_LIST
, then.
Is there any reason for the order of the items in the stack that are used by
BUILD_LIST
be what they are right now?If items were in the reverse order to what's currently done, then it could be implemented very similarly to
BUILD_TUPLE
(by stealing the references from the stack), avoiding a lot of stack pointer adjustments while items are being popped.