Skip to content

Update extending/embedding docs to new way to build modules in C #70702

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

Closed
brettcannon opened this issue Mar 9, 2016 · 6 comments
Closed

Update extending/embedding docs to new way to build modules in C #70702

brettcannon opened this issue Mar 9, 2016 · 6 comments
Labels
3.9 only security fixes docs Documentation in the Doc dir type-feature A feature request or enhancement

Comments

@brettcannon
Copy link
Member

BPO 26515
Nosy @brettcannon, @ncoghlan, @encukou, @ericsnowcurrently, @berkerpeksag
PRs
  • bpo-26515: Update C API docs to use PyModuleDef_Init() #8682
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = None
    created_at = <Date 2016-03-09.02:43:41.063>
    labels = ['type-feature', '3.9', 'docs']
    title = 'Update extending/embedding docs to new way to build modules in C'
    updated_at = <Date 2020-12-15.15:36:08.559>
    user = 'https://github.com/brettcannon'

    bugs.python.org fields:

    activity = <Date 2020-12-15.15:36:08.559>
    actor = 'petr.viktorin'
    assignee = 'docs@python'
    closed = False
    closed_date = None
    closer = None
    components = ['Documentation']
    creation = <Date 2016-03-09.02:43:41.063>
    creator = 'brett.cannon'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 26515
    keywords = ['patch']
    message_count = 5.0
    messages = ['261398', '342668', '359792', '379432', '383069']
    nosy_count = 6.0
    nosy_names = ['brett.cannon', 'ncoghlan', 'petr.viktorin', 'docs@python', 'eric.snow', 'berker.peksag']
    pr_nums = ['8682']
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue26515'
    versions = ['Python 3.9']

    @brettcannon
    Copy link
    Member Author

    https://docs.python.org/3/extending/extending.html#a-simple-example uses PyModule_Create() instead of PyModuleDef_Init().

    @brettcannon brettcannon added the docs Documentation in the Doc dir label Mar 9, 2016
    @berkerpeksag berkerpeksag added 3.7 (EOL) end of life 3.8 (EOL) end of life type-feature A feature request or enhancement labels Aug 6, 2018
    @encukou
    Copy link
    Member

    encukou commented May 16, 2019

    Correct usage of multi-phase init might now get users stuck when they start needing per-module state. See PEP-573 "Module State Access from C Extension Methods" for the (hopefully) last thing that prevents me from generally recommending multi-phase init.

    That PEP is on my list for after PRP 590 is done.
    Before it's implemented, I'm happy leaving PyModuleDef_Init to experts -- that is, have it in the reference docs only.

    @ncoghlan
    Copy link
    Contributor

    Changed target version as per Petr's comment (PEP-573 is close to being accepted for 3.9 - it just needs some editing to improve clarity in the PEP itself, rather than needing any changes to the technical proposal)

    @ncoghlan ncoghlan added 3.9 only security fixes and removed 3.7 (EOL) end of life 3.8 (EOL) end of life labels Jan 11, 2020
    @encukou
    Copy link
    Member

    encukou commented Oct 23, 2020

    There is now PEP-630. Still not done enough to move it out of draft status, but usable for converting simple modules.

    @encukou
    Copy link
    Member

    encukou commented Dec 15, 2020

    PEP-630 is now Active. I believe the vast majority of modules can now be ported, and it should be helpful for early adopters (including CPython stdlib). But there are still Open Issues and the API not battle-tested on all the edge cases.

    The PEP is written to be easily integrated into official docs when the time comes.

    @encukou
    Copy link
    Member

    encukou commented Jun 4, 2025

    See PEP-573 "Module State Access from C Extension Methods" for the (hopefully) last thing that prevents me from generally recommending multi-phase init.

    the perfectionist in me still sees rough edges a few more years (and PEPs) later, but we now have critical mass. Single-phase init is legacy.

    @encukou encukou closed this as completed Jun 4, 2025
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.9 only security fixes docs Documentation in the Doc dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    4 participants