Op 24-11-15 om 22:14 schreef BartC: > On 24/11/2015 20:54, Antoon Pardon wrote: >> Op 24-11-15 om 20:15 schreef Ian Kelly: >> >>>> But no matter what you want to call it. The dis module shows that >>>> -42 is treated in exactly the same way as 42, which is treated >>>> exactly the same way as () or as (5, 8, 13) which is treated >>>> differently from [] or [5, 8, 13]. >>> >>> This is an implementation detail. The compiler would also be free to >>> compile -42 into byte code as the negation of the constant 42. That 42 >>> is a literal, on the other hand, is part of the language >>> specification. >> >> I think you are picking nits. Sure the byte code could compile -42 into >> a byte code for 42 and a negation. Just as it could compile 42 into byte >> code for adding 32, 8 and 2. >> >> The point is, that the reverse isn't true. It couldn't compile [5, 8, 13] >> into a LOAD_CONST. > > I think it can, with a couple of extra instructions:
Sure it can with a couple of extra instructions. With extra instructions you can always use constants to build a mutable. The point is that a tuple can just be loaded as a constant without needing something extra. -- Antoon. -- https://mail.python.org/mailman/listinfo/python-list