pzthon: decorators. crazy 
>>> def outer():
... x = 1
... def inner():
... print x
... return inner
...
>>> outer()
<function inner at 0x7f7bd7ac5938>
>>> dis.dis(outer())
4 0 LOAD_DEREF 0 (x)
3 PRINT_ITEM
4 PRINT_NEWLINE
5 LOAD_CONST 0 (None)
8 RETURN_VALUE
>>> dis.dis(outer)
2 0 LOAD_CONST 1 (1)
3 STORE_DEREF 0 (x)

3 6 LOAD_CLOSURE 0 (x)
9 BUILD_TUPLE 1
12 LOAD_CONST 2 (<code object inner at 0x7f7bd7ab5300, file "<stdin>", line 3>)
15 MAKE_CLOSURE 0
18 STORE_FAST 0 (inner)

5 21 LOAD_FAST 0 (inner)
24 RETURN_VALUE





[ add comment ]   |  [ 0 trackbacks ]   |  permalink  |  related link

<<First <Back | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | Next> Last>>