Re: A couple of questions about pyrex
Greg Ewing <[email protected]> Wed, 13 May 2009 12:24:28 +1200
| Newsgroups | gmane.comp.python.pyrex |
|---|---|
| Message-ID | <[email protected]> |
Yingjie Lan wrote: > Then can we > say that we make this distinction between 'cdef class' and > 'class' by checking if the class body contains any > statement treated as native? No, that's not sufficient. Pyrex treats special methods (__add__ etc.) very differently in extension types. In a Python class, they're just ordinary Python methods. In an extension class, they're C functions that are plugged directly into the relevant slots of the type object, and they have different signatures. And before you ask, no, we couldn't use 'cdef __add__', because that already means something else (it defines a C method, which is like a virtual method in C++). -- Greg