[Python-Dev] C API changes
Antoine Pitrou
solipsis at pitrou.net
Fri Nov 30 14:33:49 EST 2018
On Fri, 30 Nov 2018 13:06:11 -0600
Neil Schemenauer <nas-python at arctrix.com> wrote:
> On 2018-11-29, Armin Rigo wrote:
> > ...Also, although I'm discussing it here, I think the whole approach
> > would be better if done as a third-party extension for now, without
> > requiring changes to CPython---just use the existing C API to
> > implement the CPython version.
>
> Hello Armin,
>
> Thank you for providing your input on this subject. I too like the
> idea of an API "shim layer" as a separate project.
>
> What do you think of writing the shim layer in C++? I'm not a C++
> programmer but my understanding is that modern C++ compilers are
> much better than years ago. Using C++ would allow us to provide a
> higher level API with smaller runtime costs.
The main problem with exposing a C++ *API* is that all people
implementing that API suddenly must understand and implement the C++
*ABI* (with itself varies from platform to platform :-)). That's
trivially easy if your implementation is itself written in C++, but not
if it's written in something else such as RPython, Java, Rust, etc.
C is really the lingua franca when exposing an interface that can be
understood, implemented and/or interfaced with from many different
languages.
So I'd turn the proposal on its head: you can implement the internals
of your interpreter or object layer in C++ (and indeed I think it
would be crazy to start writing a new Python VM in raw C), but you
should still expose a C-compatible API for third-party providers and
consumers.
Regards
Antoine.
More information about the Python-Dev
mailing list