> [email protected] wrote:
>> Dear developer of cython,
>>
>> First of all I thank you for all your work. Thanks to Cython and the
>> documentation and tutorial that you displayed on internet, I have
>> successfully managed to create a cython code approximately 250 times
>> quicker than with python and even 1.4times quicker than C.
>>
>> In fact I created two cython codes corresponding to two python codes of
>> the same algorithm (one with a single function and one with several
>> classes and function).
>>
>> I hesitated several minutes before posting in this list or in the user
>> list but since this is not simple cython problem but a problem with the
>> new version of cython, i have finally chosen to post here. I hope I made
>> the right choice.
>>
>> I downloaded the version 0.13 of cython yesterday (I was previously
>> using
>> the version 0.12.1) and two problems appeared when I used cython.
>>
>> The first one is that it seems that we can no more combine cpdef and
>> decorator :
>>
>> @cython.boundscheck(False)
>> @cython.wraparound(False)
>> cpdef run(self,adjacencyMatrix_,nodesPosition_,int
>> dimension,nbLink_):
>> ^
>> ------------------------------------------------------------
>>
>> /homelocal/max/Memoire/Sources/CAttractionRepulsionAlgorithm.pyx:48:4:
>> Decorators can only be followed by functions
>>
>> I have the same problem with cdef and I have not the problem with def.
>>
> This is a bug. Thanks for reporting, filed at
> http://trac.cython.org/cython_trac/ticket/522.
>
> In the meantime, you can use declarations such as np.ndarray[int,
> ndim=2, negative_indices=False] for the same effect.
>
This seems to reduce the time computation but not as
@cython.boundscheck(False)
@cython.wraparound(False)
Speedup between decorators and nothing = 1.5 (and not 2 as mentionned
previously)
Speedup between negative_indices=False and nothing = 1.25
>> The second problem is that it seems that we can nore more used
>> @cython.wraparound(False).
>> I have this error
>>
>> @cython.wraparound(False)
>> ^
>> ------------------------------------------------------------
>>
>> /homelocal/max/Memoire/Sources/CAttractionRepulsionAlgorithm.pyx:47:4:
>> 'wraparound' not a valid cython attribute or is being used incorrectly
>>
>> and this error for the same line :
>>
>> @cython.wraparound(False)
>> ^
>> ------------------------------------------------------------
>>
>> /homelocal/max/Memoire/Sources/CAttractionRepulsionAlgorithm.pyx:47:4:
>> 'wraparound' not a valid cython language construct
>>
>
> I do not understand you. Can you provide some more context (some more
> lines around where this happened, or an entire file which is as small as
> possible but reproduce the error). Are you sure you remembered to
> "cimport cython"?
Sorry, after sending the email, I was thinking that I had given too few
informations.
Here is the first part of my code :
import CWiredSpace
cimport CWiredSpace
import numpy as np
cimport numpy as np
import time as t
cimport cython
DTYPE = np.int
DTYPEF = np.float
ctypedef np.int_t DTYPE_t
ctypedef np.float_t DTYPEF_t
cdef extern from "math.h":
double sqrt(double)
double min(double,double)
double max(double,double)
cdef inline double double_min(double a, double b): return a if a <= b else b
cdef inline double double_max(double a, double b): return a if a >= b else b
cdef class AttractionRepulsionAlgorithm:
'''
classdocs
'''
cdef int _nbIteration
cdef int _startAttraction
cdef double _Temperature
cdef CWiredSpace.WiredSpace _WiredSpace
def __init__(self,int nbIteration, int startAttraction, double
temperature,WiredSpace):
'''
Constructor
'''
self._nbIteration = nbIteration
self._startAttraction = startAttraction
self._Temperature = temperature
self._WiredSpace = WiredSpace
@cython.boundscheck(False)
@cython.wraparound(False)
def run(self,adjacencyMatrix_,nodesPosition_,int dimension,nbLink_):
Maxime Melchior.
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev