In [1]:
%load_ext Cython
In [2]:
%%cython
cdef void foo0():
return
def main0():
cdef:
int i, n=10**6
for i in range(n):
foo0()
In [3]:
%%timeit
main0()
In [4]:
%%cython
cdef int foo0bis():
return 1
def main0bis():
cdef:
int i, n=10**6
for i in range(n):
foo0bis()
In [5]:
%%timeit
main0bis()
In [6]:
%%cython
cdef int foo1() except -1:
return 1
def main1():
cdef:
int i, n=10**6
for i in range(n):
foo1()
In [7]:
%%timeit
main1()
In [8]:
%%cython
cdef int foo2() except? -1:
return 1
def main2():
cdef:
int i, n=10**6
for i in range(n):
foo2()
In [9]:
%%timeit
main2()
In [10]:
%%cython
cdef int foo2bis() except? -1:
return -1
def main2bis():
cdef:
int i, n=10**6
for i in range(n):
foo2bis()
In [11]:
%%timeit
main2bis()
In [12]:
%%cython
cdef int foo3() except *:
return 1
def main3():
cdef:
int i, n=10**6
for i in range(n):
foo3()
In [13]:
%%timeit
main3()
In [ ]: