GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Implement PEP 793 – PyModExport · Issue #140550 · python/cpython

Implement PEP 793 – PyModExport #140550

New issue
Copy link
New issue
Copy link
Open
Open
Implement PEP 793 – PyModExport#140550
Copy link
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-C-APItype-featureA feature request or enhancementA feature request or enhancement

Description

@encukou
encukou
opened on Oct 24, 2025
Issue body actions

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.)


  • Initial implementation (gh-140550: Initial implementation of PEP 793 – PyModExport #140556)
  • Docs:
    • Reference docs (gh-140550: PEP 793 reference documentation #141197)
      • Soft-deprecate PyInit_* (gh-140550: PEP 793 reference documentation #141197)
      • Better explanation of module state (gh-140550: PEP 793 reference documentation #141197)
      • Give an example for tokens (gh-140550: PEP 793 reference documentation #141197)
    • What's New
      • a notice for DYNLOADFILE users? (edit: This shouldn't have changed/broken more than usual.)
    • Porting guide HOWTO
      • Document that the export hook runs without GIL in FT builds (see #141780) (gh-140550: Docs notes for PEP 793 #151661)
    • Tutorial update (gh-134160: Start "Extending and embedding" with a Diataxis-style tutorial #142314)
    • Mentions in PyImport_AppendInittab & friends (gh-140550: Docs notes for PEP 793 #151661)
    • Make sure references to new API are linked:
      • PyMod_Execin PyImport_CreateModuleFromInitfunc docs is linked (gh-140550: PEP 793 reference documentation #141197)
      • PyMODEXPORT_FUNC in blurb for #141672
      • blurb for #141780
  • xxlimited.c update (gh-140550: Update xxlimited with 3.15 limited API & PEP 697 #142827)
    • Remove/replace _Py_OPAQUE_PYOBJECT in xxlimited.c (by 3.15.0 beta)

Optional stretch goals:

  • Remove the PyInit function from Lib/test/test_cext/extension.c (gh-140550: Remove PyInit function from test_cext #141511)
  • Speed & size improvements
    • importdl: load the DLL once
    • bool for the GIL flag (gh-140550: Use a bool for the Py_mod_gil value #141519)
  • No longer require spec.name in PyModule_FromSlotsAndSpec
  • No longer require static allocation for Py_mod_methods
  • Add a PyModule_GetStateWithToken() function

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

No response

Linked PRs

  • gh-140550: Initial implementation of PEP 793 – PyModExport #140556
  • gh-140550: Run make regen-limited-abi #141056
  • gh-140550: PEP 793 reference documentation #141197
  • gh-140550: Remove PyInit function from test_cext #141511
  • gh-140550: Use a bool for the Py_mod_gil value #141519
  • gh-140550: Correct error message for PyModExport (PEP 793) hook #142583
  • gh-140550: Update xxlimited with 3.15 limited API & PEP 697 #142827
  • gh-140550: allow slots that repeat information from PyModuleDef #144340
  • gh-140550: Single What's New highlight for PEPs 793, 803 and 820 #149397
  • [3.15] gh-140550: Update xxlimited with 3.15 limited API (GH-142827) #149785
  • gh-140550: Docs notes for PEP 793 #151661
  • [3.15] gh-140550: Docs additions & fixups for PEP 793 (GH-151661) #152064
  • gh-140550: Enable limited C API tests on Free Threading in test_cext #157493
  • [3.15] gh-140550: Fix PyABIInfo_VAR macro: avoid ";" #157494
  • gh-140550: Fix PyABIInfo_VAR macro: avoid ";" #157539
  • [3.15] gh-140550: Enable limited C API tests on Free Threading in test_cext (GH-157493) #157560

See also:

  • gh-141671: PyMODINIT_FUNC: apply __declspec(dllexport) on Windows #141672
  • gh-134160: Start "Extending and embedding" with a Diataxis-style tutorial #142314
Reacted by Tan Long and Peter Bierma
Reacted by Stan Ulbrych and Peter Bierma
Reacted by Bartosz Sławecki

Activity

Next
  1. encukou
    added
    type-featureA feature request or enhancementA feature request or enhancement
    on Oct 24, 2025
  2. StanFromIreland
    added
    interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)
    topic-C-API
    on Oct 24, 2025
  3. encukou
    added a commit that references this issue on Nov 5, 2025

    gh-140550: Initial implementation of PEP 793 – PyModExport (GH-140556)

    589a03a
  4. vstinner
    added 2 commits that reference this issue on Nov 5, 2025

    pythongh-140550: Run make regen-limited-abi

    dd03049

    gh-140550: Run make regen-limited-abi (#141056)

    579b2f8
  5. encukou
    added 2 commits that reference this issue on Nov 7, 2025

    pythongh-140550: PEP 793 reference documentation

    0142b5d

    pythongh-140550: Removp PyInit function from test_cext

    1ad68bf
  6. encukou commented on Nov 13, 2025

    @encukou
    encukou
    on Nov 13, 2025
    MemberAuthor
    More actions

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

  7. encukou
    added 2 commits that reference this issue on Nov 13, 2025

    pythongh-140550: Use a bool for the Py_mod_gil value

    36dcf00

    gh-140550: Use a bool for the Py_mod_gil value (GH-141519)

    a4dd662
  8. encukou
    added a commit that references this issue on Nov 26, 2025

    gh-140550: PEP 793 reference documentation (GH-141197)

    d7f0214
  9. StanFromIreland
    added 3 commits that reference this issue on Dec 6, 2025

    pythongh-140550: Initial implementation of PEP 793 – PyModExport (pyt…

    7e30dee

    pythongh-140550: Run make regen-limited-abi (python#141056)

    2d83666

    pythongh-140550: Use a bool for the Py_mod_gil value (pythonGH-141519)

    ae32d26
  10. 10 remaining items

  11. davin-core commented on Mar 24, 2026

    @davin-core
    davin-core
    on Mar 24, 2026
    More actions

    @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?

  12. ljfp
    added a commit that references this issue on Apr 25, 2026

    pythongh-140550: allow slots that repeat information from PyModuleDef (…

    4c9469d
  13. encukou
    added a commit that references this issue on May 5, 2026

    gh-140550: Single What's New highlight for PEPs 793, 803 and 820 (GH-…

    02d02f4
  14. encukou
    added 2 commits that reference this issue on May 13, 2026

    gh-140550: Update xxlimited with 3.15 limited API (GH-142827)

    fa81cd9

    [3.15] gh-140550: Update xxlimited with 3.15 limited API (GH-142827) (G…

    b650305
  15. encukou commented on Jun 18, 2026

    @encukou
    encukou
    on Jun 18, 2026
    MemberAuthor
    More actions

    @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
  16. encukou
    added 2 commits that reference this issue on Jun 24, 2026

    gh-140550: Docs additions & fixups for PEP 793 (GH-151661)

    763cc22

    [3.15] gh-140550: Docs additions & fixups for PEP 793 (GH-151661) (GH…

    bc52a01
  17. vstinner
    added 2 commits that reference this issue on Sep 14, 2026

    pythongh-140550: Enable limited C API tests on Free Threading in test…

    3e76111

    pythongh-140550: Enable limited C API tests on Free Threading in test…

    9bed8d3
  18. encukou
    added a commit that references this issue on Sep 15, 2026

    pythongh-140550: Fix PyABIInfo_VAR macro: avoid ";"

    9435e20
  19. hugovk
    added 2 commits that reference this issue on Sep 15, 2026

    gh-140550: Fix PyABIInfo_VAR macro: avoid ";" (#157539)

    cbb43b8

    [3.15] gh-140550: Fix PyABIInfo_VAR macro: avoid ";" (#157494)

    4b6de96
  20. vstinner
    added a commit that references this issue on Sep 15, 2026

    gh-140550: Enable limited C API tests on Free Threading in test_cext (#…

    fb123c8
  21. serhiy-storchaka
    added a commit that references this issue on Oct 10, 2026

    [3.15] gh-140550: Enable limited C API tests on Free Threading in tes…

    96f7177
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

    interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-C-APItype-featureA feature request or enhancementA feature request or enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.