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

Refactored nanobind so that it works with Py_LIMITED_API #37

Merged
merged 1 commit into from
May 26, 2022

Conversation

wjakob
Copy link
Owner

@wjakob wjakob commented May 26, 2022

There is an ongoing effort to refactor CPython internals to improve its
performance. This has serious consequences for tools like nanobind,
which rely on various CPython implementation details that are now
subject to change.

This commit changes nanobind so that it can (optionally) work via the
Py_LIMITED_API, which means that it treats all CPython data structures
as fully opaque and only accesses them through an official API/ABI with
long-term stability.

This requires a change that is pending for inclusion into Python 3.12
as part of PR 93012.

There is an ongoing effort to refactor CPython internals to improve its
performance. This has serious consequences for tools like nanobind,
which rely on various CPython implementation details that are now
subject to change.

This commit changes nanobind so that it can (optionally) work via the
Py_LIMITED_API, which means that it treats all CPython data structures
as fully opaque and only accesses them through an official API/ABI with
long-term stability.

This requires a change that is pending for inclusion into Python 3.11
(issue 39012).
@wjakob wjakob merged commit be84fff into master May 26, 2022
Comment on lines +202 to +205
# Limited API interface only supported in Python >= 3.12
if ((Python_VERSION_MAJOR EQUAL 3) AND (Python_VERSION_MINOR LESS 12))
set(ARG_STABLE_ABI OFF)
endif()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this set to 3.12? The documentation mentions:

Python 3.2 introduced the Limited API, a subset of Python’s C API.

so I would have assumed that 3.2 is sufficient.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nanobind depends on a few features that I specifically worked on adding to the stable ABI (search for my name here: https://docs.python.org/3.12/whatsnew/3.12.html). That means they are only usable in stable ABI builds targeting 3.12+ (so not very useful just yet, but good to have for the future).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants