|
|
|
|
|
by ul5255
5292 days ago
|
|
Strange. With Python 2.6 I get [None, 7] while with Python 2.7 it is [None]. Looking at the OP codes the 2.7 one's look weird. Python 2.6: >>> dis.dis(f)
1 0 LOAD_GLOBAL 0 (g)
3 LOAD_CONST 0 (None)
6 YIELD_VALUE
7 CALL_FUNCTION 1
10 RETURN_VALUE
Python 2.7: >>> dis.dis(f)
1 0 LOAD_GLOBAL 0 (g)
3 LOAD_CONST 0 (None)
6 YIELD_VALUE
7 CALL_FUNCTION 1
10 POP_TOP
11 LOAD_CONST 0 (None)
14 RETURN_VALUE
In essence the Python 2.7 compiler decides to throw away the result of the g() function call and replaces it with None. Does anyone understand why? |
|