DAtum

EDA, Software and Business of technology
Greek, 'loxos: slanting. To displace or remove from its proper place
da·tums A point, line, or surface used as a reference


                        ... disruption results in new equilibria


[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:
« Home | Next »
| Next »
| Next »
| Next »
| Next »
| Next »
| Next »
|