Am 20. April 2018 11:19:32 MESZ schrieb Hongduo Sun:
>I have the example as follows:
>
>test.pyx:
>cdef test_func(long i):
> cdef long j
> for j in xrange(i):
> j=i
Note that this is useless code. The C Compiler will discard it. Just use an empty function.
>test.pxd:
>cdef test_func(long i)
>
>---------------------------------------------
>
>test1.pyx:
>import test
>for i in xrange(10000000):
> test.test_func(1000000000000000)
This cannot work. Your actual code is probably different, or you forgot to rebuild after the last change, or something like that.
>test2.pyx:
>from test cimport test_func
>for i in xrange(10000000):
> test_func(1000000000000000)
>-------------------------------------------------
>
>When running test1 and test2, I found test1 is about 20 times faster
>than
>test2.
>In my personal perspective, I suppose these two should running with
>similar
>speed.
>Do anyone have any idea about what caused the difference?
Question is: what did you want to benchmark?
Stefan