[Pyrex] C methods in extension types

Andreas Kostyrka andreas at mtg.co.at
Tue Oct 7 13:12:43 CEST 2003


On Tue, Oct 07, 2003 at 12:28:55PM +0200, Francesc Alted wrote:
> Hi Greg,
> 
> I'm just curious about the advantages of having C methods in extension types
> that you recently introduced in pyrex 0.9. Would that mean they can be
> called from C code, for example? Can you put some practical example if that
> is possible at all?
Well one thing that I can think of is, are helper methods.

Currently, one is forced to do:

cdef class MyClass
cdef int myhelper(MyClass self, args):
   ...
cdef class MyClass:
   ...
   ...
   # somewhere here:
   myhelper(self, "args")
   # and actually it would read much nicer
   self.myhelper("args")

Basically the current design doesn't allow one to keep all the needed
helper in one place.
And no, having these helpers is the idea in using a Pyrex builtin, so
that reading one character from the input buffer is fast (no string
objects to create, no python method call, etc.).

Andreas




More information about the Pyrex mailing list