You can use the dis module to display something like the assembler code for a function.
import dis
dis.dis(lambda x, y, z: x + y * z)
1 0 LOAD_FAST 0 (x)
3 LOAD_FAST 1 (y)
6 LOAD_FAST 2 (z)
9 BINARY_MULTIPLY
10 BINARY_ADD
11 RETURN_VALUE
dis.dis(lambda x, y, z: (x + y) * z)
1 0 LOAD_FAST 0 (x)
3 LOAD_FAST 1 (y)
6 BINARY_ADD
7 LOAD_FAST 2 (z)
10 BINARY_MULTIPLY
11 RETURN_VALUE
I don't understand assembler and I don't know when it will be useful, but I've posted it as a test for Qiita.
Recommended Posts