Title: Add a Module Def Slot for Supporting Multiple Interpreters · Issue #104108 · python/cpython · GitHub
Open Graph Title: Add a Module Def Slot for Supporting Multiple Interpreters · Issue #104108 · python/cpython
X Title: Add a Module Def Slot for Supporting Multiple Interpreters · Issue #104108 · python/cpython
Description: PEP 489 is clear that extension modules implementing multi-phase init are expected to support use in multiple interpreters. However, there are two situations where that mandate isn't sufficient: PEP 684 introduces a per-interpreter GIL, ...
Open Graph Description: PEP 489 is clear that extension modules implementing multi-phase init are expected to support use in multiple interpreters. However, there are two situations where that mandate isn't sufficient: PE...
X Description: PEP 489 is clear that extension modules implementing multi-phase init are expected to support use in multiple interpreters. However, there are two situations where that mandate isn't sufficient...
Opengraph URL: https://github.com/python/cpython/issues/104108
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Add a Module Def Slot for Supporting Multiple Interpreters","articleBody":"PEP 489 is clear that extension modules implementing multi-phase init are expected to support use in multiple interpreters. However, there are two situations where that mandate isn't sufficient:\r\n\r\n1. PEP 684 introduces a per-interpreter GIL, where there is an additional thread-safety constraint beyond support for multiple interpreters\r\n2. the HPy project implies modules with multi-phase init but not necessarily supporting multiple interpreters\r\n\r\nIn both cases a new module def slot (the same one, in fact) is a correct solution.\r\n\r\nFor per-interpreter GIL, [PEP 684 specifies](https://peps.python.org/pep-0684/#extension-module-thread-safety) that we must add a module def slot for opting in to supporting per-interpreter GIL.\r\n\r\nFor HPy, the situation was pointed out to me by @hodgestar during a conversation at PyCon.\r\n\r\nCC @encukou\r\n\r\n----\r\n\r\nI propose the following solution:\r\n\r\n1. add a new `Py_mod_multiple_interpreters` module def slot\r\n2. interpret the value to indicate support for multiple interpreters and for per-interpreter GIL\r\n3. call `_PyImport_CheckSubinterpIncompatibleExtensionAllowed()` when appropriate in `PyModule_FromDefAndSpec2()`\r\n\r\nThe slot value may be one of the following:\r\n\r\n* `0` - does not support multiple interpreters (for HPy)\r\n* `1` - supports multiple interpreters (the default)\r\n* `2` - supports per-interpreter GIL\r\n\r\nIt would probably make sense to define a constant (macro) for each of those.\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-104148\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/ericsnowcurrently","@type":"Person","name":"ericsnowcurrently"},"datePublished":"2023-05-02T23:37:33.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":12},"url":"https://github.com/104108/cpython/issues/104108"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:4ff37e1c-3a67-d6cd-d714-bd1ce1b276ab |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A5E0:4CEB4:13ABB1:1A7B59:6969C81F |
| html-safe-nonce | e4e35654aa94f089172f03667769d70ad68db80942a62db9e864e5a0369bfc40 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNUUwOjRDRUI0OjEzQUJCMToxQTdCNTk6Njk2OUM4MUYiLCJ2aXNpdG9yX2lkIjoiNTk0MTQzODc3NDU4OTM3ODg3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | c45260a681d912236eabed7b818f89d7a32795717ff0825a585c1fc69e3fbf75 |
| hovercard-subject-tag | issue:1693220564 |
| 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/_view_fragments/issues/show/python/cpython/104108/issue_layout |
| twitter:image | https://opengraph.githubassets.com/f596c95a848dac323b2dd4645af0b4786ec6237af5abdde40da85f0ed99595bb/python/cpython/issues/104108 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/f596c95a848dac323b2dd4645af0b4786ec6237af5abdde40da85f0ed99595bb/python/cpython/issues/104108 |
| og:image:alt | PEP 489 is clear that extension modules implementing multi-phase init are expected to support use in multiple interpreters. However, there are two situations where that mandate isn't sufficient: PE... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ericsnowcurrently |
| hostname | github.com |
| expected-hostname | github.com |
| None | acedec8b5f975d9e3d494ddd8f949b0b8a0de59d393901e26f73df9dcba80056 |
| turbo-cache-control | no-preview |
| 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 | 83c08c21cdda978090dc44364b71aa5bc6dcea79 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width