Visitar URL original
Implement PEP 793 – PyModExport · Issue #140550 · python/cpython · GitHub
Skip to content

Implement PEP 793 – PyModExport #140550

Description

@encukou

Feature or enhancement

Proposal:

See PEP 793. I'll copy the abstract for reference:

In this PEP, we propose a new entry point for C extension modules, by which one can define a module using an array of PyModuleDef_Slot structures without an enclosing PyModuleDef structure. This allows extension authors to avoid using a statically allocated PyObject, lifting the most common obstacle to making one compiled library file usable with both regular and free-threaded builds of CPython.

To make this viable, we also specify new module slot types to replace PyModuleDef’s fields, and to allow adding a token similar to the Py_tp_token used for type objects.

We also add an API for defining modules from slots dynamically.

The existing API (PyInit_*) is soft-deprecated. (That is: it will continue to work without warnings, and it’ll be fully documented and supported, but we plan to not add any new features to it.)


Optional stretch goals:

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

No response

Linked PRs

See also:

Activity

  1. added a commit that references this issue on Nov 5, 2025
  2. added 2 commits that reference this issue on Nov 5, 2025
  3. added 2 commits that reference this issue on Nov 7, 2025
  4. encukou commented on Nov 13, 2025

    @encukou
    MemberAuthor

    I'd appreciate a review of the reference docs update: #141197

  5. added 2 commits that reference this issue on Nov 13, 2025
  6. added a commit that references this issue on Nov 26, 2025
  7. added 3 commits that reference this issue on Dec 6, 2025
  8. 9 remaining items

  9. added a commit that references this issue on Feb 15, 2026
  10. davin-core commented on Mar 24, 2026

    @davin-core

    @encukou I am trying to update a library to include this feature in 3.15, and I am wondering if the PY_VERSION_HEX for this version is 0x030F0000. Does this version exist?

  11. added a commit that references this issue on Apr 25, 2026
  12. added a commit that references this issue on May 5, 2026
  13. added 2 commits that reference this issue on May 13, 2026
  14. encukou commented on Jun 18, 2026

    @encukou
    MemberAuthor

    @davin-core

    I am trying to update a library to include this feature in 3.15, and I am wondering if the PY_VERSION_HEX for this version is 0x030F0000. Does this version exist?

    Sorry, I missed the notification.

    To use wording in the docs: 0x030F0000 does not correspond to any Python release, but is useful in numeric comparisons.

    You can use 0x030F0000 to mean "3.15+" in e.g.:

    • PY_VERSION_HEX >= 0x030F0000
    • #define Py_LIMITED_API 0x030F0000
    • #define Py_TARGET_ABI3T 0x030F0000
  15. added 2 commits that reference this issue on Jun 24, 2026
  16. added 2 commits that reference this issue on Sep 14, 2026
  17. added a commit that references this issue on Sep 15, 2026
  18. added 2 commits that reference this issue on Sep 15, 2026
  19. added a commit that references this issue on Sep 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions