Closed nayefc closed 6 years ago
@nayefc seems you're running the non-cythonized version twice.
In [2]: import cython
...: import statically
...: from IPython import get_ipython
...: ipython = get_ipython()
...:
...: W = 100
...: X = 999
...: Y = 103.13
...:
...: def calcpy(a, b, c):
...: val = 0
...: for i in range(100):
...: val += a + b * c + i
...: return val
...:
...: @statically.typed
...: def calcc(a: cython.int, b: cython.int, c: cython.float):
...: val: cython.float
...: i: cython.int
...: for i in range(100):
...: val += a + b * c + i
...: return val
...:
...: print('py:')
...: ipython.magic("timeit calcpy(W, X, Y)")
...: print('c in py:')
...: ipython.magic("timeit calcc(W, X, Y)")
...:
...:
py:
13.9 µs ± 238 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)
c in py:
251 ns ± 3.88 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each)
Oops... thanks!
Hello,
Any idea why both of these run in 15.5us?
Are my
val
andi
variables not getting cythonized properly?