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

Lenard Lindstrom len-l at telus.net
Wed Feb 14 19:05:15 UTC 2007


Stefan Behnel wrote:
> Hi,
>
> Greg Ewing wrote:
>   
>> Stefan Behnel wrote:
>>     
>>> 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?
>
>   
.pxd files could be extended to accept C variable definitions and 
function prototypes. These would be exported using CObjects. cimporting 
such a .pxd file would trigger Pyrex's magic. It would leave "public" 
definitions for static linking.

Personally I do not like using function prototypes in the above 
suggestion. IMHO the need to specify a function's formal arguments more 
than once is unpythonic. But it is consistent with C and .pxd file usage.

-- 
Lenard Lindstrom
<len-l at telus.net>





More information about the Pyrex mailing list