[Pyrex] [PATCH] public C-API and Py_ssize_t support for 0.9.5.1a

Stefan Behnel stefan_ml at behnel.de
Wed Feb 14 13:52:34 UTC 2007


Hi,

Greg Ewing wrote:
> Stefan Behnel wrote:
>> It uses the preferred
>> way of providing C-APIs taken from
>>
>> http://docs.python.org/ext/using-cobjects.html
> 
> It sounds fairly similar to what I had in mind,
> i.e. wrapping each exported function in a PyCObject.

... though mine is much easier to use from plain C code - just include the
generated header file, call the init function - and all exported functions are
statically defined and ready to call.


>> That's just three simple lines of Pyrex code to interface
>> with an external module at both Python- and C-level.
> 
> It would be nice if I could get it down to just one line,
> i.e. the cimport statement. Seems like it should be possible
> for Pyrex to generate the rest automatically from the info
> in the .pxd file. I'll look into it.

You could still get down to 2 lines, if you did some magic in the background,
including the double import also as a Python module - which is handy, as you
would normally not export every function at the C level. Some things are
better exported through Python.

How would you know from the cimported .pxd that it describes a public C-API in
Pyrex style? i.e., how would Pyrex's magic be triggered?

Stefan



More information about the Pyrex mailing list