Is it possible to put something onto the stack from within one of the methods inside of If so, can you point me to an example?

At 09:33 AM 1/11/2010, Philip Cannata wrote:
Okay, I think this is going to be a big help, thanks.

At 02:53 AM 1/11/2010, Tobias Ivarsson wrote:
What do you mean by "return value"?

Based on the context that you have posted questions about the compiler before I'm going to answer what list comprehension is compiled to.

List comprehension (in python in general, both CPython and Jython) is compiled to:
1. Create an empty list
2. Iterate through the iterator(s) of the comprehension expression
3. for each iteration evaluate the elt and add this value to the list created in step 1
4. when the evaluation of the list comprehension is over, the list created at step 1, that now contains additional elements is left on the stack.

This is done in org.python.compiler.CodeCompiler#visitListComp line 2107.

The code in visitListComp restructures the list comprehension to an equivalent (nested) for loop where the append method of the result list is stored in a temporary variable and invoked in the body. The result list is left on the stack throughout the entire iteration, and is still there when the for loop ends.


On Mon, Jan 11, 2010 at 3:17 AM, Philip Cannata <> wrote:
Hello, can anyone tell me where in the code the return value is set
for listcomprehension?

This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
Jython-dev mailing list