[Pyrex] calling cdef'ed functions between pyrex modules

Greg Ewing greg.ewing at canterbury.ac.nz
Tue Dec 21 02:09:24 CET 2004


Robby Dermody wrote:
> For any given one of these pyrex modules, it needs to
> make calls to cdef functions in any of the other pyrex modules.

Exporting top-level C functions to another Pyrex module
isn't currently supported.

> I really don't
> want to stick everything in a single .pyx file...it would be a few
> thousand lines of pyrex code in a single file...

You could keep the parts in .pxi files included by the
main .pyx file. There wouldn't be much difference then,
except for compilation time.

> I'm guessing that I'll have to encapsulate this C 
 > functionality as a pyrex extension type

That's probably the easiest way, if you really want
them to be separate modules from Python's point of
view.

 > But what about the performance of this solution?

It should be pretty fast. A C slot in the extension
type instance points to a table of C function pointers.
If you keep a reference to the instance in a C variable,
it will only be a couple of memory accesses slower than
calling a C function directly.

--
Greg




More information about the Pyrex mailing list