Skip to content

Instantly share code, notes, and snippets.

@jason-s
Last active August 29, 2015 14:12
Show Gist options
  • Save jason-s/d947f32ea3d3504a24a6 to your computer and use it in GitHub Desktop.
Save jason-s/d947f32ea3d3504a24a6 to your computer and use it in GitHub Desktop.
jit test
import numba
def foo(x):
return 1 < x < 7
def bar(x):
_x_0 = x
_x_1 = 1 < _x_0
if not _x_1:
_x_2 = False
else:
_x_2 = _x_0 < 7
return _x_2
print 'numba version = %s' % numba.__version__
pyfuncs = {'foo':foo, 'bar':bar}
jitfuncs = {}
for fname,f in pyfuncs.iteritems():
print fname
llvm = numba.compiler.compile_isolated(f,(numba.types.int32,))
try:
print llvm.llvm_func
except Exception as e:
print e
jitfuncs[fname] = numba.jit('b1(i4)')(f)
for x in range(9):
print "x=%s, jit(foo)(x)=%s, jit(bar)(x)=%s" % (x,jitfuncs['foo'](x),jitfuncs['bar'](x))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment