[Python-Dev] C API changes

Nick Coghlan ncoghlan at gmail.com
Sat Nov 24 12:27:34 EST 2018


On Fri, 23 Nov 2018 at 23:24, Armin Rigo <armin.rigo at gmail.com> wrote
(regarding opaque "handles" in the C API):
> The C API would change a lot, so it's not reasonable to do that in the
> CPython repo.  But it could be a third-party project, attempting to
> define an API like this and implement it well on top of both CPython
> and PyPy.  IMHO this might be a better idea than just changing the API
> of functions defined long ago to make them more regular (e.g. stop
> returning borrowed references); by now this would mostly mean creating
> more work for the PyPy team to track and adapt to the changes, with no
> real benefits.

And the nice thing about doing it as a shim is that it can be applied
to *existing* versions of CPython, rather than having to wait for new
ones.

Node.js started switching over to doing things this way last year, and
its a good way to go about it:
https://medium.com/the-node-js-collection/n-api-next-generation-node-js-apis-for-native-modules-169af5235b06

While this would still be a difficult project to pursue, and would
suffer from many of the same barriers to adoption as CPython's native
stable ABI, it does offer a concrete benefit to 3rd party module
authors: being able to create single wheel files that can be shared
across multiple Python versions, rather than needing to be built
separately for each one.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia


More information about the Python-Dev mailing list