[Python] Disassemble code, lambdas
Here's two nice python features:
>>dis.dis(f)
0 LOAD_CONST 1 (1)
3 LOAD_CONST 2 (2)
6 BINARY_ADD
7 RETURN_VALUE
>>dis.dis(g)
0 LOAD_CONST 1 (1)
3 LOAD_CONST 2 (2)
6 BINARY_ADD
7 RETURN_VALUE
|
- Lambda's are unnamed pseudo-functions, which are a functional programming tool
def f (x): return x**2
Lambdas
f = lambda x: x**2
Usage(for both)
print g(8)
- To disassemble python code and see their bytecode (python can also precompile your code ...somewhat like java)
>>dis.dis(f)
0 LOAD_CONST 1 (1)
3 LOAD_CONST 2 (2)
6 BINARY_ADD
7 RETURN_VALUE
>>dis.dis(g)
0 LOAD_CONST 1 (1)
3 LOAD_CONST 2 (2)
6 BINARY_ADD
7 RETURN_VALUE
|