Lambdacurry

[Python] Disassemble code, lambdas


Here’s two nice python features:

  • Lambda’s are unnamed pseudo-functions, which are a functional programming tool

normal functions `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)

>>import dis >>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

del.icio.us Tags: python lambda software


Lambdacurry

[Python] Disassemble code, lambdas

Published

December 23, 2004

Find me on Twitter @sandeepssrin

Did i make any mistake? Please consider sending a pull request.