Skip to content

Instantly share code, notes, and snippets.

@sklam
Last active August 29, 2015 14:05
Show Gist options
  • Save sklam/c3e575197af9cbf4e2f1 to your computer and use it in GitHub Desktop.
Save sklam/c3e575197af9cbf4e2f1 to your computer and use it in GitHub Desktop.
Getting Numba compiler internal structures
from numba import bytecode, interpreter, ir
def foo(a, b):
c = 0
for i in range(a):
for j in range(b):
c += i + j
return c
bc = bytecode.ByteCode(func=foo)
intrp =interpreter.Interpreter(bytecode=bc)
intrp.interpret()
print("CFG info".center(80, '='))
intrp.cfa.dump() # CFG
print("DFG info".center(80, '='))
intrp.dfa.dump()
intrp.dump() # Dump the Numba IR
print("Getting the entry block".center(80, '='))
firstblock = intrp.blocks[intrp.cfa.blockseq[0]] # entry block
firstblock.dump()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment