decorators question
Fredrik Lundh
fredrik at pythonware.com
Mon Dec 4 17:44:40 EST 2006
Carsten Haese wrote:
> * The function body gets compiled into byte code (but not executed).
careful: when you get as far as executing the "def" statement, the
function body has already been compiled. the byte code for the function
is stored as a module-level constant:
>>> code = compile("def func(arg): print arg", "", "exec")
>>> dis.dis(code)
1 0 LOAD_CONST 0 (<code object func ...>)
3 MAKE_FUNCTION 0
6 STORE_NAME 0 (func)
...
> * A callable object with the byte code for the compiled function body is
> constructed.
> * The thusly constructed callable object is bound to the name A in your
> current namespace.
</F>
More information about the Python-list
mailing list