| python Programming Glossary: disWhy does Python code run faster in a function? http://stackoverflow.com/questions/11241523/why-does-python-code-run-faster-in-a-function  at toplevel it is a global. To examine bytecode use the dis module . I was able to disassemble the function directly but.. To examine bytecode use the dis module . I was able to disassemble the function directly but to disassemble the toplevel.. . I was able to disassemble the function directly but to disassemble the toplevel code I had to use the compile builtin ... 
 How should I understand the output of dis.dis? http://stackoverflow.com/questions/12673074/how-should-i-understand-the-output-of-dis-dis  should I understand the output of dis.dis  I would like to understand how to use dis the dissembler.. should I understand the output of dis.dis  I would like to understand how to use dis the dissembler of.. output of dis.dis  I would like to understand how to use dis the dissembler of Python bytecode . Specifically how should.. 
 Accessing class variables from a list comprehension in the class definition http://stackoverflow.com/questions/13905741/accessing-class-variables-from-a-list-comprehension-in-the-class-definition  class ™s suite finishes execution its execution frame is discarded but its local namespace is saved . 4 A class object is.. you ever wanted You can see this all in action using the dis module . I'm using Python 3.3 in the following examples because.. line and executes that as if it were a function import dis def foo ... class Foo ... x 5 ... y x for i in range 1 ... return.. 
 Find out into how many values a return value will be unpacked http://stackoverflow.com/questions/16481156/find-out-into-how-many-values-a-return-value-will-be-unpacked  number of values the caller is exp import inspect import dis def expecting offset 0 Return how many values the caller is.. f.f_code.co_code instruction ord bytecode i if instruction dis.opmap 'UNPACK_SEQUENCE' return ord bytecode i 1 elif instruction.. 'UNPACK_SEQUENCE' return ord bytecode i 1 elif instruction dis.opmap 'POP_TOP' return 0 else return 1 def count # offset 3.. 
 What do backticks mean to the python interpreter: `num` http://stackoverflow.com/questions/1673071/what-do-backticks-mean-to-the-python-interpreter-num  namespace for __repr__ respectively. EDIT Using the dis module proves my assumption def f1 a return repr a def f2 a.. a.__repr__ def f3 a return `a` Disassembling shows import dis dis.dis f1 3 0 LOAD_GLOBAL 0 repr  3 LOAD_FAST 0 a  6 CALL_FUNCTION.. def f3 a return `a` Disassembling shows import dis dis.dis f1 3 0 LOAD_GLOBAL 0 repr  3 LOAD_FAST 0 a  6 CALL_FUNCTION.. 
 Python `if x is not None` or `if not x is None`? http://stackoverflow.com/questions/2710940/python-if-x-is-not-none-or-if-not-x-is-none  Python 2.6.2 r262 71600 Apr 15 2009 07 20 39 import dis def f x ... return x is not None ... dis.dis f 2 0 LOAD_FAST.. 07 20 39 import dis def f x ... return x is not None ... dis.dis f 2 0 LOAD_FAST 0 x  3 LOAD_CONST 0 None  6 COMPARE_OP 9.. 20 39 import dis def f x ... return x is not None ... dis.dis f 2 0 LOAD_FAST 0 x  3 LOAD_CONST 0 None  6 COMPARE_OP 9 is.. 
 Python Compilation/Interpretation Process http://stackoverflow.com/questions/3299648/python-compilation-interpretation-process  operation is indicated. You can see this bytecode with the dis module as follows def fib n return n if n 2 else fib n 2 fib.. return n if n 2 else fib n 2 fib n 1 ... fib 10 55 import dis dis.dis fib 1 0 LOAD_FAST 0 n  3 LOAD_CONST 1 2  6 COMPARE_OP.. n if n 2 else fib n 2 fib n 1 ... fib 10 55 import dis dis.dis fib 1 0 LOAD_FAST 0 n  3 LOAD_CONST 1 2  6 COMPARE_OP 0.. 
 if loop: x not in VS not x in [duplicate] http://stackoverflow.com/questions/3481554/if-loop-x-not-in-vs-not-x-in  make identical bytecode as you can clearly verify import dis dis.dis compile 'if x not in d pass' '' 'exec' 1 0 LOAD_NAME.. identical bytecode as you can clearly verify import dis dis.dis compile 'if x not in d pass' '' 'exec' 1 0 LOAD_NAME 0 x.. bytecode as you can clearly verify import dis dis.dis compile 'if x not in d pass' '' 'exec' 1 0 LOAD_NAME 0 x  3.. 
 while (1) Vs. for while(True) — Why is there a difference? http://stackoverflow.com/questions/3815359/while-1-vs-for-whiletrue-why-is-there-a-difference  not the case in python2.7. The following script import dis def while_one while 1 pass def while_true while True pass print.. pass def while_true while True pass print while 1 print   dis.dis while_one print while True print   dis.dis while_true produces.. def while_true while True pass print while 1 print   dis.dis while_one print while True print   dis.dis while_true produces.. 
 Free Python decompiler that is not an online service? [closed] http://stackoverflow.com/questions/48211/free-python-decompiler-that-is-not-an-online-service  service that you need to upload a pyc or pyo file to the dis module allows you to disassemble but not decompile bytecode.. upload a pyc or pyo file to the dis module allows you to disassemble but not decompile bytecode decompile.py works only for.. 
 Are tuples more efficient than lists in Python? http://stackoverflow.com/questions/68630/are-tuples-more-efficient-than-lists-in-python   python performance   share improve this question   The dis module disassembles the byte code for a function and is useful.. performance   share improve this question   The dis module disassembles the byte code for a function and is useful to see the.. 5 ... y x 2 ... def b ... x 1 2 3 4 5 ... y x 2 ... import dis dis.dis a 2 0 LOAD_CONST 1 1  3 LOAD_CONST 2 2  6 LOAD_CONST.. 
 Is Python interpreted or compiled or both? http://stackoverflow.com/questions/6889747/is-python-interpreted-or-compiled-or-both  is interpreted compiled too but it's still an important distinction both because it aids understanding and because there.. statement a b.c is compiled to a byte stream which when disassembled looks somewhat like load 0 b load_str 'c' get_attr.. low level you can experiment with the standard library dis module and see what the real deal looks like. Interpreting this.. 
 In Python, what is the difference between “.append()” and “+= []”?  http://stackoverflow.com/questions/725782/in-python-what-is-the-difference-between-append-and  BUILD_LIST outweighs LOAD_ATTR CALL_FUNCTION . import dis dis.dis compile s s.append 'spam' '' 'exec' 1 0 BUILD_LIST 0.. BUILD_LIST outweighs LOAD_ATTR CALL_FUNCTION . import dis dis.dis compile s s.append 'spam' '' 'exec' 1 0 BUILD_LIST 0 3 STORE_NAME.. outweighs LOAD_ATTR CALL_FUNCTION . import dis dis.dis compile s s.append 'spam' '' 'exec' 1 0 BUILD_LIST 0 3 STORE_NAME.. 
 Order of syntax for using 'not' and 'in' keywords http://stackoverflow.com/questions/8738388/order-of-syntax-for-using-not-and-in-keywords  than an in operation and then negating the result import dis def notin 'ham' not in 'spam and eggs' dis.dis notin 2 0 LOAD_CONST.. result import dis def notin 'ham' not in 'spam and eggs' dis.dis notin 2 0 LOAD_CONST 1 'ham'  3 LOAD_CONST 2 'spam and eggs'.. import dis def notin 'ham' not in 'spam and eggs' dis.dis notin 2 0 LOAD_CONST 1 'ham'  3 LOAD_CONST 2 'spam and eggs'.. 
 |