[Python-3000] Dict literal bytecode
Greg Ewing
greg.ewing at canterbury.ac.nz
Fri Mar 28 23:27:30 CET 2008
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