Title: GitHub · Where software is built
Open Graph Title: python/cpython
X Title: python/cpython
Description: The Python programming language. Contribute to python/cpython development by creating an account on GitHub.
Open Graph Description: The Python programming language. Contribute to python/cpython development by creating an account on GitHub.
X Description: The Python programming language. Contribute to python/cpython development by creating an account on GitHub.
Opengraph URL: https://github.com/python/cpython
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Add a mechanism for single-phase init modules to declare free-threading compatibility","articleBody":"# Feature or enhancement\r\n\r\n### Proposal:\r\n\r\ngh-116322 only works for modules using multi-phase init; we need an alternative mechanism for for single-phase init modules since they can't provide `m_slots`.\r\n\r\nWe originally considered indicating compatibility in the symbol table of the `.so` containing the module, either by the presence of a magic symbol, or by providing an alternate init function with a `PyInitT_` prefix. As pointed out by @Yhg1s in Discord, that solution doesn't work with modules added to inittab.\r\n\r\nThe current proposal is:\r\n- Before calling any module init function, enable the GIL if it is disabled (this will most likely be done as part of gh-116882).\r\n- In free-threaded builds, add a `void *md_gil` member to `PyModuleObject`. It defaults to `Py_MOD_GIL_USED` (the same constant from gh-116322).\r\n- Introduce a new public C API function `PyModule_SetGIL(PyObject *mod, void *gil)`. If a single-phase init module can run without the GIL, it will call `PyModule_SetGIL(mod, Py_MOD_GIL_NOT_USED)` in its init function. This function will be a no-op in normal builds, and will set `md_gil` to its argument in free-threaded builds.\r\n- After the init function returns, if the module's `md_gil` member is set to `Py_MOD_GIL_NOT_USED` and the GIL was disabled before calling the init function, disable the GIL.","author":{"url":"https://github.com/swtaarrs","@type":"Person","name":"swtaarrs"},"datePublished":"2024-04-03T22:29:07.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/117526/cpython/issues/117526"}
| route-pattern | /:user_id/:repository/issues/:id(.:format) |
| route-controller | issues |
| route-action | show |
| fetch-nonce | v2:4dbb66d8-f053-cc76-f704-babc5f71638b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 97FA:11169F:23A5EB2:2EB3ACF:696B15A8 |
| html-safe-nonce | 7ac287d227e7c6b37f6bd07ea1e5b2554f92890296522f0557f68a083f43dc64 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5N0ZBOjExMTY5RjoyM0E1RUIyOjJFQjNBQ0Y6Njk2QjE1QTgiLCJ2aXNpdG9yX2lkIjoiMjg4MjgyMzM5ODQ5Mzk4NDE2OCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 211e3380fc1c59a2fdcfa16d745334c9a8f4370a647befff6c0c85f75911c612 |
| hovercard-subject-tag | repository:81598961 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/python/cpython/issues/117526 |
| twitter:image | https://opengraph.githubassets.com/8ad8e9ec5c315c6d51b8515f2b78fb581344c187f6fdc162080c35a74e1a51ba/python/cpython |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/8ad8e9ec5c315c6d51b8515f2b78fb581344c187f6fdc162080c35a74e1a51ba/python/cpython |
| og:image:alt | The Python programming language. Contribute to python/cpython development by creating an account on GitHub. |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5f99f7c1d70f01da5b93e5ca90303359738944d8ab470e396496262c66e60b8d |
| turbo-cache-control | no-cache |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 82560a55c6b2054555076f46e683151ee28a19bc |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width