Title: [C API] Revert of private functions removed in Python 3.13 causing most problems · Issue #112026 · python/cpython · GitHub
Open Graph Title: [C API] Revert of private functions removed in Python 3.13 causing most problems · Issue #112026 · python/cpython
X Title: [C API] Revert of private functions removed in Python 3.13 causing most problems · Issue #112026 · python/cpython
Description: Copy of my Discourse message. Hi, My C API: My plan to clarify private vs public functions in Python 3.13 uses Python 3.13 beta 1 (May 2024) as deadline to make most C extensions compatible with Python 3.13. Problem: I wasn't prepared fo...
Open Graph Description: Copy of my Discourse message. Hi, My C API: My plan to clarify private vs public functions in Python 3.13 uses Python 3.13 beta 1 (May 2024) as deadline to make most C extensions compatible with Py...
X Description: Copy of my Discourse message. Hi, My C API: My plan to clarify private vs public functions in Python 3.13 uses Python 3.13 beta 1 (May 2024) as deadline to make most C extensions compatible with Py...
Opengraph URL: https://github.com/python/cpython/issues/112026
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[C API] Revert of private functions removed in Python 3.13 causing most problems","articleBody":"Copy of my [Discourse message](https://discuss.python.org/t/revert-python-3-13-c-api-incompatible-changes-causing-most-troubles/38214).\r\n\r\nHi,\r\n\r\nMy [C API: My plan to clarify private vs public functions in Python 3.13](https://discuss.python.org/t/c-api-my-plan-to-clarify-private-vs-public-functions-in-python-3-13/30131) uses Python 3.13 beta 1 (May 2024) as deadline to make most C extensions compatible with Python 3.13.\r\n\r\nProblem: **I wasn't prepared for the number of people eagger to test their project on Python 3.13 alpha 1 as soon as it was released.** Some people are working on porting their own code to Python 3.13, whereas others are blocked by dependencies not compatible yet. **For Python 3.12, it took months** to get Cython (7 months) and numpy (10 months) to become compatible (with a release), and apparently people were fine with this pace. I expected to have 6 months to go through issues and make decisions on a case by case basis. But Cython was made compatible with Python 3.13 (alpha1) in 1 week! Well, for the Cython case, becoming compatible mostly means \"disable optimizations\" sadly. I don't want Cython (or other projects) to become slower.\r\n\r\nOverall, it's great that people test Python 3.13 alpha 1! I love that, getting feedback as soon as possible! I want to encourage that and help people who are going through issue.\r\n\r\nI'm still bug triaging C API reports, whereas some people ask to get Python 3.13 being fixed \"right now\". My plan is about designing public C API to replace removed privated functions, but this work takes time since we want to design \"future proof\" API which cover most use cases, expose less implementation details, and following the [latest C API guidelines](https://devguide.python.org/developer-workflow/c-api/index.html). It's not just \"take the private API and put it in the public C API\": even if new public functions are added, they will not be drop-in replacements (there might be more work than \"remove the underscore prefix\").\r\n\r\nI tried to communicate as much as I can in advance about my plan removing private C functions. **Now that the changes are done, the impact is known better, and we should reevaluate the situation with these new information.**\r\n\r\nAnother problem is that it's unclear to me how C API decisions are taken. Latest C API questions to the Steering Council were delegated to the future C API Working Group, but the [Working Group doesn't exist yet](https://github.com/python/steering-council/issues/210).\r\n\r\n---\r\n\r\nSo well, let me propose concrete actions.\r\n\r\nWhat should be done right now:\r\n\r\n* **Revert** immediately C API changes impacting at least 5 projects. My colleague Karolina did a [great bug triage work on couting build failures per C API issue](https://discuss.python.org/t/ongoing-packages-rebuild-with-python-3-13-in-fedora/38134) by recompiling 4000+ Python packages in Fedora with Python 3.13.\r\n* Consider reverting more changes on a case by case basis.\r\n\r\nWhat should be done next:\r\n\r\n* For removed functions which impact at least one project but we decide to not revert, document a solution in What's New in Python 3.13 (even if the function was \"private\", usually we don't document changes related to private APIs). I expected the existing public C API to be complete enough, but the devil is in the details, and \"it's complicated\". Some functions are only available in the private/internal C API, there is \"no good\" replacement in the public C API. Well, that's the part that I'm trying to fix.\r\n* Add better public C API function to replace private C API functions.\r\n* Help projects to migrate to better public C API functions.\r\n\r\nWhat can be done in the long term:\r\n\r\n* Clarify what ``_Py`` prefix means: does it mean \"can be changed anytime, no backward compatibility\"? Or does mean \"it depends...\"?\r\n* Design a new approach to introduce incompatible C API changes. IMO the most practical one would be to introduce the concept of a \"compatibility version\" and let C extensions opt-in for \"future\" incompatible changes. It may give more control on who is impacted and when. For example, you can target the \"C API version 3.15\" and you will be impacted by all planned changes, especially deprecated functions scheduled for removal.\r\n* Design guidelines on how to introduce incompatible changes.\r\n\r\n---\r\n\r\nThe overall plan on private APIs was done in the frame of the [private API contract](https://docs.python.org/dev/c-api/stable.html):\r\n\r\n\u003e Names prefixed by an underscore, such as _Py_InternalState, are private API that **can change without notice** even in patch releases.\r\n\r\nWell. That's the theory, and the practice shows me that users have \"different expectations\". Apparently, we have to update/complete this contract...\r\n\r\n---\r\n\r\nIf we revert private C API function removals, does it mean that these **private** functions become part of the **public** C API and have to stay forever, be documented and tested? Or would they move back to their previous state: not supported and \"can change anything (which includes being removed)\"?\r\n\r\n---\r\n\r\nSee also:\r\n\r\n* [Is Python 3.13 going to be Python 4?](https://discuss.python.org/t/is-python-3-13-going-to-be-python-4/37490) discussion\r\n* [C API: Meta issue to replace removed functions with new clean public functions](https://github.com/python/cpython/issues/111481)\r\n* [C API: Remove private C API functions (move them to the internal C API)](https://github.com/python/cpython/issues/106320#issuecomment-1762776276): link to recent discussions in this issue. I asked people to create new issues, since this one history is too long, but people prefer to commenting this issues instead.\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-112046\n* gh-112115\n* gh-112119\n* gh-112121\n* gh-112171\n* gh-119855\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/vstinner","@type":"Person","name":"vstinner"},"datePublished":"2023-11-13T11:00:41.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":10},"url":"https://github.com/112026/cpython/issues/112026"}
| 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:8801be20-5ae4-8f80-c622-ea9df160f291 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DDF8:1219C5:6EFEB:9C841:696A0C50 |
| html-safe-nonce | 8fac30c3dfe43db7ddc07d912b249b25ac81ee408e422d0551f936b63132e36b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEREY4OjEyMTlDNTo2RUZFQjo5Qzg0MTo2OTZBMEM1MCIsInZpc2l0b3JfaWQiOiIxNTkxMDA4NzgwNDUyNzYwNjU2IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 1ef554f756fe328dfefbee08a64268a088b250d52414b14f82721e4d4c429742 |
| hovercard-subject-tag | issue:1990412474 |
| 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/112026/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d5a68266fed77c7c3827055cea899d0b5591188a5d24a287859d09828732ccd2/python/cpython/issues/112026 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d5a68266fed77c7c3827055cea899d0b5591188a5d24a287859d09828732ccd2/python/cpython/issues/112026 |
| og:image:alt | Copy of my Discourse message. Hi, My C API: My plan to clarify private vs public functions in Python 3.13 uses Python 3.13 beta 1 (May 2024) as deadline to make most C extensions compatible with Py... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | vstinner |
| hostname | github.com |
| expected-hostname | github.com |
| None | 699227a00bbb7fe1eec276d2ae1c3a93068bc5ba483bd9dc4b2a27a8f4f2f595 |
| 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 | 7266b2d935baa1c6474b16dd9feaa5ca30607261 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width