René's URL Explorer Experiment


Title: Please restore _Py_InitializeMain or provide an alternate API for it · Issue #142417 · python/cpython · GitHub

Open Graph Title: Please restore _Py_InitializeMain or provide an alternate API for it · Issue #142417 · python/cpython

X Title: Please restore _Py_InitializeMain or provide an alternate API for it · Issue #142417 · python/cpython

Description: As discussed in #129033, opening a new issue at the request of @vstinner. See #129033 (comment) for the reasons this API is needed. In short, a way to run python code and insert a meta importer into sys.meta_path before the "main" phase ...

Open Graph Description: As discussed in #129033, opening a new issue at the request of @vstinner. See #129033 (comment) for the reasons this API is needed. In short, a way to run python code and insert a meta importer int...

X Description: As discussed in #129033, opening a new issue at the request of @vstinner. See #129033 (comment) for the reasons this API is needed. In short, a way to run python code and insert a meta importer int...

Opengraph URL: https://github.com/python/cpython/issues/142417

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Please restore _Py_InitializeMain or provide an alternate API for it","articleBody":"As discussed in #129033, opening a new issue at the request of @vstinner. See https://github.com/python/cpython/issues/129033#issuecomment-3626066338 for the reasons this API is needed. \n\nIn short, a way to run python code and insert a meta importer into sys.meta_path *before* the \"main\" phase of initialization runs is needed. This allows, for instance, to bundle all python code as pre-compiled bytecode into a single mmapped file and directly load it from there for improved performance and hygiene.\n\nI am aware that the state of the interpreter after \"core\" initialization is not entirely specified, however, in practice it is complete enough to write a meta path importer.\n\nThis facility has been used for many years by at least two projects that I know of:  bypy (link to source code) https://github.com/kovidgoyal/bypy/blob/master/bypy/freeze/bypy-freeze.h#L835 and PyOxidizer: https://github.com/indygreg/PyOxidizer/blob/1ceca8664c71f39e849ce4873e00d821504b32bd/pyembed/src/technotes.rs#L155 \n\nI dont much care about this API in particular, but I would like some way to hook into the initialization process after \"core\" initialization and before \"main\" initialization.\n\nSome context about use case. bypy is used in the calibre and kitty programs, both of which embed a \"frozen\" Python interpreter. _Py_InitializeMain() allows that frozen importer to import all its python code, including stdlib code from a single mmaped file contianing pre-compiled bytecode. This has obvious performance benefits especially on windows.\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-142420\n* gh-143877\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/kovidgoyal","@type":"Person","name":"kovidgoyal"},"datePublished":"2025-12-08T13:22:01.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":6},"url":"https://github.com/142417/cpython/issues/142417"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:a09e64ce-af79-0760-e89c-4f924046800d
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idE03C:144C84:BD5A86:109791F:696A2A41
html-safe-noncec0a5ade92f531918d58a33cc645b147a1f5e116a4b3600b056e639dbd699cc49
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMDNDOjE0NEM4NDpCRDVBODY6MTA5NzkxRjo2OTZBMkE0MSIsInZpc2l0b3JfaWQiOiI3MDk5OTgxOTc2MDM3ODk0NzIxIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmacf560b9b6610b7a118ec91174e05cb3cf56d87cfa2b45d0657ad3075beb8f82c5
hovercard-subject-tagissue:3706385020
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/142417/issue_layout
twitter:imagehttps://opengraph.githubassets.com/6f3ae20c516099596f209df5835a10c71a88688fad4d605b960bff2f8922a4fc/python/cpython/issues/142417
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/6f3ae20c516099596f209df5835a10c71a88688fad4d605b960bff2f8922a4fc/python/cpython/issues/142417
og:image:altAs discussed in #129033, opening a new issue at the request of @vstinner. See #129033 (comment) for the reasons this API is needed. In short, a way to run python code and insert a meta importer int...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamekovidgoyal
hostnamegithub.com
expected-hostnamegithub.com
Nonea1022f03e4f0d91ea173e4e5dac892c982e0588c62f1ce56121d755a320a3569
turbo-cache-controlno-preview
go-importgithub.com/python/cpython git https://github.com/python/cpython.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id81598961
octolytics-dimension-repository_nwopython/cpython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id81598961
octolytics-dimension-repository_network_root_nwopython/cpython
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasef472b8e6c7b3fdd5d0354972a3f4c516289bf0be
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python/cpython/issues/142417#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F142417
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F142417
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=python%2Fcpython
Reloadhttps://github.com/python/cpython/issues/142417
Reloadhttps://github.com/python/cpython/issues/142417
Reloadhttps://github.com/python/cpython/issues/142417
python https://github.com/python
cpythonhttps://github.com/python/cpython
Please reload this pagehttps://github.com/python/cpython/issues/142417
Notifications https://github.com/login?return_to=%2Fpython%2Fcpython
Fork 33.9k https://github.com/login?return_to=%2Fpython%2Fcpython
Star 71.1k https://github.com/login?return_to=%2Fpython%2Fcpython
Code https://github.com/python/cpython
Issues 5k+ https://github.com/python/cpython/issues
Pull requests 2.1k https://github.com/python/cpython/pulls
Actions https://github.com/python/cpython/actions
Projects 31 https://github.com/python/cpython/projects
Security Uh oh! There was an error while loading. Please reload this page. https://github.com/python/cpython/security
Please reload this pagehttps://github.com/python/cpython/issues/142417
Insights https://github.com/python/cpython/pulse
Code https://github.com/python/cpython
Issues https://github.com/python/cpython/issues
Pull requests https://github.com/python/cpython/pulls
Actions https://github.com/python/cpython/actions
Projects https://github.com/python/cpython/projects
Security https://github.com/python/cpython/security
Insights https://github.com/python/cpython/pulse
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/142417
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/142417
Please restore _Py_InitializeMain or provide an alternate API for ithttps://github.com/python/cpython/issues/142417#top
interpreter-core(Objects, Python, Grammar, and Parser dirs)https://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22interpreter-core%22
topic-C-APIhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22topic-C-API%22
type-featureA feature request or enhancementhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-feature%22
https://github.com/kovidgoyal
https://github.com/kovidgoyal
kovidgoyalhttps://github.com/kovidgoyal
on Dec 8, 2025https://github.com/python/cpython/issues/142417#issue-3706385020
#129033https://github.com/python/cpython/issues/129033
@vstinnerhttps://github.com/vstinner
#129033 (comment)https://github.com/python/cpython/issues/129033#issuecomment-3626066338
https://github.com/kovidgoyal/bypy/blob/master/bypy/freeze/bypy-freeze.h#L835https://github.com/kovidgoyal/bypy/blob/master/bypy/freeze/bypy-freeze.h#L835
https://github.com/indygreg/PyOxidizer/blob/1ceca8664c71f39e849ce4873e00d821504b32bd/pyembed/src/technotes.rs#L155https://github.com/indygreg/PyOxidizer/blob/1ceca8664c71f39e849ce4873e00d821504b32bd/pyembed/src/technotes.rs#L155
gh-142417: Add PyInitConfig_SetInitCallback() function #142420https://github.com/python/cpython/pull/142420
gh-142417: Add Py_InitializeMain() function #143877https://github.com/python/cpython/pull/143877
interpreter-core(Objects, Python, Grammar, and Parser dirs)https://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22interpreter-core%22
topic-C-APIhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22topic-C-API%22
type-featureA feature request or enhancementhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-feature%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.