[Pyrex] where is Cython 'cpdef'
Robert Bradshaw
robertwb at math.washington.edu
Wed Oct 31 07:33:26 CET 2007
On Oct 30, 2007, at 9:13 PM, David McNab wrote:
> On Tue, 2007-10-30 at 15:45 -0700, Robert Bradshaw wrote:
>> Funny you should ask, there's a new call type in Cython that does
>> exactly this. Specifically, if you have
>>
>> cdef class Rect:
>>
>> cdef int width, height
>>
>> def __init__(self, int width, int height):
>> self.width = width
>> self.height = height
>>
>> cpdef int area(self):
>> return self.width * self.height
>>
>> It will create a (python-accessible) def function that wraps the
>> cpdef function, but if the call is made on a Rect object, e.g.
>>
>> cdef Rect my_rect = Rect(3,4)
>> print my_rect.area()
>
> Hi again Robert,
>
> I downloaded/installed Cython (zip file) a while ago to try out this
> 'cpdef' feature. But Cython doesn't support it, and barfs with a
> syntax
> error.
>
> I tried downloading from the hg repo, but same problem - no cpdef
> support.
>
> Can you please point me to the version/branch of cython that has cpdef
> support?
I'm going to be releasing that branch later tonight/tomorrow, it
looks like in the current repository it's still called rdef.
- Robert
More information about the Pyrex
mailing list