jfj wrote:
def foo(x): y= (i for i in x) return y
From the disassembly it seems that the generator is a code object but 'x' is not a cell variable. WTF?
That's because x is not assigned to anywhere in the body of foo. The bytecode compiler optimizes away the creation of a cell in this case, just passing the value of x as an implicit parameter to the generator.
How do I disassemble the generator?
You'd have to get hold of the code object for it and disassemble that. There should be a reference to it in one of the co_consts slots, I think.
-- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand http://www.cosc.canterbury.ac.nz/~greg -- http://mail.python.org/mailman/listinfo/python-list