[Python-3000] Change to class construction? (original) (raw)
Terry Reedy tjreedy at udel.edu
Sat Jul 7 19:08:15 CEST 2007
- Previous message: [Python-3000] Change to class construction?
- Next message: [Python-3000] Change to class construction?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
"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 (outermost): | %0 = [] | for x in outermost: | for y in seq2: | %0.append(x*y) # Special opcode, not a normal call | return %0 | %n = (seq1)
Why not pass both seq1 and seq2 to the function so both become locals? The difference of treatment is quite surprising.
- Previous message: [Python-3000] Change to class construction?
- Next message: [Python-3000] Change to class construction?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]