[Python-ideas] discouraging direct use of the C-API

Antoine Pitrou solipsis at pitrou.net
Thu May 7 00:16:22 CEST 2015


On Wed, 6 May 2015 13:13:57 -0400
Donald Stufft <donald at stufft.io> wrote:
> 
> > On May 6, 2015, at 12:57 PM, Antoine Pitrou <solipsis-xNDA5Wrcr86sTnJN9+BGXg at public.gmane.org> wrote:
> > 
> > On Wed, 6 May 2015 10:23:09 -0600
> > Eric Snow <ericsnowcurrently at gmail.com>
> > wrote:
> >> A big blocker to making certain sweeping changes to CPython (e.g.
> >> ref-counting) is compatibility with the vast body of C extension
> >> modules out there that use the C-API.  While there are certainly
> >> drastic long-term solutions to that problem, there is one thing we can
> >> do in the short-term that would at least get the ball rolling.  We can
> >> put a big red note at the top of every page of the C-API docs that
> >> encourages folks to either use CFFI or Cython.
> > 
> > CFFI is only useful for a small subset of stuff people use the C API for
> > (mainly, thin wrappers around external libraries). Cython is a more
> > reasonable suggestion in this context.
> 
> You can write stuff in C itself for cffi too, it’s not just for C bindings,
> an example would be the .c’s and .h’s for padding and constant time compare
> in the cryptography project [1].

That really doesn't change what I said.  CFFI is not appropriate to
write e.g. actual extension classes.

Besides, we have ctypes in the standard library, it would be stupid to
recommend CFFI and not ctypes.

Regards

Antoine.




More information about the Python-ideas mailing list