-
-
Notifications
You must be signed in to change notification settings - Fork 34.8k
gh-140550: Docs notes for PEP 793 #151661
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
base: main
Are you sure you want to change the base?
Changes from 3 commits
d7df745
cb7593c
686adff
a893b57
d304062
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -100,11 +100,29 @@ For example, a module called ``spam`` would be defined like this:: | |
| The export hook is typically the only non-\ ``static`` | ||
| item defined in the module's C source. | ||
|
|
||
| .. _pymodexport-api-caveats: | ||
|
|
||
| The hook should be kept short -- ideally, one line as above. | ||
| If you do need to use Python C API in this function, it is recommended to call | ||
| ``PyABIInfo_Check(&abi_info, "modulename")`` first to raise an exception, | ||
| If you need to use any Python C API, it is recommended to call | ||
| :c:func:`PyABIInfo_Check` first to raise an exception, | ||
| rather than crash, in common cases of ABI mismatch. | ||
| Also, note that in :term:`free-threaded <free threading>` builds the export | ||
| function may be called without the :term:`GIL` held even if the extension | ||
| specifies that the GIL is required. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you clarify what this means? "Calling with the GIL held" sounds like the old terminology for calling without an attached thread state. If export functions just need synchronization, then let's just say that.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's really the GIL here: |
||
| For example:: | ||
|
|
||
| PyMODEXPORT_FUNC | ||
| PyModExport_modulename(void) | ||
| { | ||
| if (PyABIInfo_Check(&abi_info, "modulename") < 0) { | ||
| /* ABI mismatch. It's not safe to examine the raised exception. */ | ||
| return NULL; | ||
| } | ||
|
|
||
| /* use Python API (as little as possible); don't rely on GIL */ | ||
|
|
||
| return modulename_slots; | ||
| } | ||
|
|
||
| .. note:: | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a
:term:`free-threaded build`term for this.