S Murthy <smur...@pm.me> added the comment:
@steven.daprano In this case, the method f was created by via def. And calling dis.dis(s) where s is the source code of f (say s = inspect.getsource(f)) shows the bytecode both for the header and the body, as is clear enough from the example I first posted. >>> dis.dis('def f(x): return x**2') 1 0 LOAD_CONST 0 (<code object f at 0x10b0f7f60, file "<dis>", line 1>) 2 LOAD_CONST 1 ('f') 4 MAKE_FUNCTION 0 6 STORE_NAME 0 (f) 8 LOAD_CONST 2 (None) 10 RETURN_VALUE Disassembly of <code object f at 0x10b0f7f60, file "<dis>", line 1>: 1 0 LOAD_FAST 0 (x) 2 LOAD_CONST 1 (2) 4 BINARY_POWER 6 RETURN_VALUE The first block of instructions here are for the def statement, and the second block for the return statement. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue39800> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com