Stefan Behnel added the comment:

> Stefan (Behnel), could you comment on the strategy that you had in mind?
> Is it similar to module_get_symbol.diff or entirely different?

I agree with Antoine that a Capsule would work better here (and yes, the 
performance problem of capsules is only with cases where they need to be 
unpacked frequently). Here is our current API for datetime as an example:

https://github.com/cython/cython/blob/e6c13f8922d6406f64f2578f5a0041e1615291a3/Cython/Includes/cpython/datetime.pxd

It's not great (it would be possible to make it look more OOP-ish), but it's 
simple and quite easy to use. The top of the file contains the necessary header 
declarations, and the rest are inline C wrapper functions that basically just 
rename the existing capsule C-API functions and macros to make them easily and 
nicely callable from Cython code without having to care about the Capsule and 
its list of C functions.

The declarations for _cdecimal would use a similar scheme and additionally 
include the libmpdec header declarations so that users could work with the 
underlying C data directly with a single (c-)import. That would then require 
the libmpdec symbols to be available, though, also when it's linked internally 
into _cdecimal.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue22194>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to