1 May 2012 09:53
[Cython] Code generated for the expression int(x)+1
Hi all,
I am having a simple performance problem that can be resolved by splitting up an expression in two lines. I
don't know if it is a bug or I am missing something.
The piece of code below is translated to slow code
1)
cdef int i
i=int(x)+1
whereas the code below is translated to fast code
2)
cdef int i
i=int(x)
i=i+1
Snippet of generated code by cython
1)
/* "test.pyx":4
* cdef double x=3.2
* cdef int i
* i=int(x)+1 # <<<<<<<<<<<<<<
* return i
*
*/
__pyx_t_1 = PyFloat_FromDouble(__pyx_v_x); if (unlikely(!__pyx_t_1)) {__pyx_filename =
(Continue reading)
RSS Feed