[Python-3000] Change to class construction?
Terry Reedy
tjreedy at udel.edu
Sat Jul 7 19:08:15 CEST 2007
"Nick Coghlan" <ncoghlan at gmail.com> wrote in message
news:468FA01A.6040707 at gmail.com...
| Georg is correct. A list comprehension like:
|
| [(x * y) for x in seq1 for y in seq2]
|
| expands to the following in 2.x (% prefixes the compiler's hidden
| variables):
|
| %n = []
| for x in seq1:
| for y in seq2:
| %n.append(x*y) # Special opcode, not a normal call
|
| In py3k it expands to:
|
| def <anon>(outermost):
| %0 = []
| for x in outermost:
| for y in seq2:
| %0.append(x*y) # Special opcode, not a normal call
| return %0
| %n = <anon>(seq1)
Why not pass both seq1 *and* seq2 to the function so both become locals?
The difference of treatment is quite surprising.
More information about the Python-3000
mailing list