[Python-3000] Dict literal bytecode

Terry Reedy tjreedy at udel.edu
Sat Mar 29 05:54:15 CET 2008


"Greg Ewing" <greg.ewing at canterbury.ac.nz> wrote in message 
news:47ED70D2.6030509 at canterbury.ac.nz...
Marcin ‘Qrczak’ Kowalczyk wrote:
> What about lists? I guess (haven't checked) that they are made like
> tuples.

I always thought they were built one item at a time,
but I was wrong (see below). So there doesn't seem to
be much logic or consistency here at all.
 >>> def f():
... x = [1,2,3]
...
 >>> from dis import dis
 >>> dis(f)
 2 0 LOAD_CONST 1 (1)
 3 LOAD_CONST 2 (2)
 6 LOAD_CONST 3 (3)
 9 BUILD_LIST 3
 12 STORE_FAST 0 (x)
 15 LOAD_CONST 0 (None)
 18 RETURN_VALUE
-- 
Greg 


More information about the Python-3000 mailing list

AltStyle によって変換されたページ (->オリジナル) /