Title: "mem" and "object" Allocators are No Longer Protected by the GIL · Issue #105766 · python/cpython · GitHub
Open Graph Title: "mem" and "object" Allocators are No Longer Protected by the GIL · Issue #105766 · python/cpython
X Title: "mem" and "object" Allocators are No Longer Protected by the GIL · Issue #105766 · python/cpython
Description: Once we moved to per-interpreter GIL, the promises in the docs no longer hold: ...where the allocation must be performed with the GIL held. It's still fine for pymalloc, but any custom, non-wrapping "mem"/"object" allocators would need t...
Open Graph Description: Once we moved to per-interpreter GIL, the promises in the docs no longer hold: ...where the allocation must be performed with the GIL held. It's still fine for pymalloc, but any custom, non-wrappin...
X Description: Once we moved to per-interpreter GIL, the promises in the docs no longer hold: ...where the allocation must be performed with the GIL held. It's still fine for pymalloc, but any custom, non-wra...
Opengraph URL: https://github.com/python/cpython/issues/105766
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"\"mem\" and \"object\" Allocators are No Longer Protected by the GIL","articleBody":"Once we moved to per-interpreter GIL, the promises in [the docs](https://docs.python.org/3.12/c-api/memory.html#allocator-domains) no longer hold:\r\n\r\n```\r\n...where the allocation must be performed with the GIL held.\r\n```\r\n\r\nIt's still fine for pymalloc, but any custom, non-wrapping \"mem\"/\"object\" allocators would need to be updated to be thread-safe or per-interpreter.\r\n\r\nI have a PR up that does an okay job of adapting such allocators: gh-105619. However, it penalizes use of such an allocator in subinterpreters that have their own GIL.\r\n\r\nHonestly, I'm leaning toward documenting that such allocators must be thread-safe or per-interpreter. From what I understand, the documented guarantees (in the docs and in PEP 445) are more about representing what pymalloc needs than what custom allocators need.\r\n\r\nPerhaps the biggest question is: what projects would be impacted? I haven't had a chance yet to search for projects that use custom mem/object allocators that aren't thread-safe. I suspect there aren't more than two or three.\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-107519\n* gh-107522\n* gh-109035\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/ericsnowcurrently","@type":"Person","name":"ericsnowcurrently"},"datePublished":"2023-06-14T01:24:06.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":3},"url":"https://github.com/105766/cpython/issues/105766"}
| 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:a9bebc51-7bea-6175-5207-a370038ee57e |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BB64:B7306:2133986:2DBDE78:696AB92A |
| html-safe-nonce | e8d1ff7333175cdeebe9440c9245749ef6c53b9c9c55937ec7ac689f2a5ddb5c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQjY0OkI3MzA2OjIxMzM5ODY6MkRCREU3ODo2OTZBQjkyQSIsInZpc2l0b3JfaWQiOiIzODQyNDMzMTM2Njg2OTcxMTc5IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 5ca366d731690fd829d42878a41f7a5ad961b2f33c9619c506175c7d1a9e6019 |
| hovercard-subject-tag | issue:1755875424 |
| 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/105766/issue_layout |
| twitter:image | https://opengraph.githubassets.com/4f3740b4ccfa9a36ac59b79252c674937fe0633a96276f44204f85cbdc9afb50/python/cpython/issues/105766 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/4f3740b4ccfa9a36ac59b79252c674937fe0633a96276f44204f85cbdc9afb50/python/cpython/issues/105766 |
| og:image:alt | Once we moved to per-interpreter GIL, the promises in the docs no longer hold: ...where the allocation must be performed with the GIL held. It's still fine for pymalloc, but any custom, non-wrappin... |
| 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 | 46ce962e0e18113ea447391b6ace8b02d4d2861e57b4fbab3658698f73d8855b |
| 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 | 30300f30bb3949de255e84a146706a3bdb5c19c9 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width