Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PEP 674: GraalPython C API emulation rationale #2171

Merged
merged 2 commits into from
Dec 1, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion pep-0674.rst
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,23 @@ HPy to provide direct equivalents. Any macro that references

These statements are endorsed by Antonio Cuni (HPy developer).

GraalVM Python
--------------

In GraalVM, when a Python object is accessed by the Python C API, the C API
emulation layer has to wrap the GraalVM objects into wrappers that expose
the internal structure of the CPython structures (PyObject, PyLongObject,
PyTypeObject, etc). This is because when the C code accesses it directly or via
macros, all GraalVM can intercept is a read at the struct offset, which has
to be mapped back to the representation in GraalVM. The smaller the
"effective" number of exposed struct members (by replacing macros with
functions), the simpler GraalVM wrappers can be.

This PEP alone is not enough to get rid of the wrappers in GraalVM, but it
is a step towards this long term goal. GraalVM already supports HPy which is a better
solution in the long term.

These statements are endorsed by Tim Felgentreff (GraalVM Python developer).

Specification
=============
Expand Down Expand Up @@ -290,7 +307,8 @@ so are not aware of compatibility issues with other Python
implementations.

Moreover, continuing to allow using macros as l-value does not help the
HPy project.
HPy project and leaves the burden of emulating them on GraalVM's Python
implementation.


Macros already modified
Expand Down