René's URL Explorer Experiment


Title: gh-118761: Improve import time of `subprocess` by hukkin · Pull Request #129427 · python/cpython · GitHub

Open Graph Title: gh-118761: Improve import time of `subprocess` by hukkin · Pull Request #129427 · python/cpython

X Title: gh-118761: Improve import time of `subprocess` by hukkin · Pull Request #129427 · python/cpython

Description: This makes import subprocess lazy import locale and signal. As a result, also re (imported by locale) and enum (imported by signal) imports are skipped. Benchmark import time main branch $ hyperfine --warmup 11 "./python -c 'import subprocess'" "./python -c 'pass'" Benchmark 1: ./python -c 'import subprocess' Time (mean ± σ): 24.6 ms ± 0.9 ms [User: 20.8 ms, System: 4.0 ms] Range (min … max): 23.5 ms … 28.0 ms 108 runs Benchmark 2: ./python -c 'pass' Time (mean ± σ): 10.8 ms ± 0.6 ms [User: 8.9 ms, System: 2.3 ms] Range (min … max): 10.1 ms … 14.2 ms 190 runs Summary './python -c 'pass'' ran 2.28 ± 0.16 times faster than './python -c 'import subprocess'' PR branch $ hyperfine --warmup 11 "./python -c 'import subprocess'" "./python -c 'pass'" Benchmark 1: ./python -c 'import subprocess' Time (mean ± σ): 18.7 ms ± 0.8 ms [User: 16.1 ms, System: 3.2 ms] Range (min … max): 17.6 ms … 21.7 ms 139 runs Benchmark 2: ./python -c 'pass' Time (mean ± σ): 10.4 ms ± 0.5 ms [User: 9.4 ms, System: 1.8 ms] Range (min … max): 9.7 ms … 12.9 ms 226 runs Summary './python -c 'pass'' ran 1.80 ± 0.11 times faster than './python -c 'import subprocess'' Benchmark subprocess.run call In fact, this not only has an effect on import time, but simple subprocess.run calls, too: main branch $ hyperfine --warmup 11 "./python -c 'import subprocess; subprocess.run([\"sleep\", \"0\"])'" "./python -c 'pass'" Benchmark 1: ./python -c 'import subprocess; subprocess.run(["sleep", "0"])' Time (mean ± σ): 26.7 ms ± 1.1 ms [User: 23.4 ms, System: 3.4 ms] Range (min … max): 25.5 ms … 31.7 ms 103 runs Benchmark 2: ./python -c 'pass' Time (mean ± σ): 11.7 ms ± 0.8 ms [User: 9.5 ms, System: 2.4 ms] Range (min … max): 10.9 ms … 15.4 ms 235 runs Summary './python -c 'pass'' ran 2.28 ± 0.18 times faster than './python -c 'import subprocess; subprocess.run(["sleep", "0"])'' PR branch $ hyperfine --warmup 11 "./python -c 'import subprocess; subprocess.run([\"sleep\", \"0\"])'" "./python -c 'pass'" Benchmark 1: ./python -c 'import subprocess; subprocess.run(["sleep", "0"])' Time (mean ± σ): 22.0 ms ± 1.3 ms [User: 18.1 ms, System: 3.9 ms] Range (min … max): 20.3 ms … 27.2 ms 119 runs Benchmark 2: ./python -c 'pass' Time (mean ± σ): 12.0 ms ± 0.4 ms [User: 9.8 ms, System: 2.3 ms] Range (min … max): 11.5 ms … 13.6 ms 224 runs Summary './python -c 'pass'' ran 1.84 ± 0.12 times faster than './python -c 'import subprocess; subprocess.run(["sleep", "0"])'' Issue: gh-118761

Open Graph Description: This makes import subprocess lazy import locale and signal. As a result, also re (imported by locale) and enum (imported by signal) imports are skipped. Benchmark import time main branch $ hyperfin...

X Description: This makes import subprocess lazy import locale and signal. As a result, also re (imported by locale) and enum (imported by signal) imports are skipped. Benchmark import time main branch $ hyperfin...

Opengraph URL: https://github.com/python/cpython/pull/129427

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/checks(.:format)
route-controllerpull_requests
route-actionchecks
fetch-noncev2:8ea21495-d630-5156-afcf-9e7687ef71c8
current-catalog-service-hash87dc3bc62d9b466312751bfd5f889726f4f1337bdff4e8be7da7c93d6c00a25a
request-idA108:3350DE:933CB:C8862:6969C3C3
html-safe-noncebb3f3ba88ee83dbbf6088b79ae23c7af2490b086452b2c5f8bfe3e2633a79185
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMTA4OjMzNTBERTo5MzNDQjpDODg2Mjo2OTY5QzNDMyIsInZpc2l0b3JfaWQiOiIyNTQwNTA5MDE2MDM0NDkzMzc5IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac7b44ff63d9fc9dc9c3a99e24fea2ce0943eb5519c51062e9114e39d94492d97a
hovercard-subject-tagpull_request:2304016188
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,checks,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/checks
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/python/cpython/pull/129427/checks
twitter:imagehttps://avatars.githubusercontent.com/u/3275109?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/3275109?s=400&v=4
og:image:altThis makes import subprocess lazy import locale and signal. As a result, also re (imported by locale) and enum (imported by signal) imports are skipped. Benchmark import time main branch $ hyperfin...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
Noneacedec8b5f975d9e3d494ddd8f949b0b8a0de59d393901e26f73df9dcba80056
turbo-cache-controlno-cache
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 full-width full-width-p-0
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release83c08c21cdda978090dc44364b71aa5bc6dcea79
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python/cpython/pull/129427/checks#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F129427%2Fchecks
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%2Fpull%2F129427%2Fchecks
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%2Fpull_requests%2Fshow%2Fchecks&source=header-repo&source_repo=python%2Fcpython
Reloadhttps://github.com/python/cpython/pull/129427/checks
Reloadhttps://github.com/python/cpython/pull/129427/checks
Reloadhttps://github.com/python/cpython/pull/129427/checks
python https://github.com/python
cpythonhttps://github.com/python/cpython
Please reload this pagehttps://github.com/python/cpython/pull/129427/checks
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/pull/129427/checks
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
Sign up for GitHub https://github.com/signup?return_to=%2Fpython%2Fcpython%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fpython%2Fcpython%2Fissues%2Fnew%2Fchoose
gpsheadhttps://github.com/gpshead
python:mainhttps://github.com/python/cpython/tree/main
hukkin:subprocess-importtimehttps://github.com/hukkin/cpython/tree/subprocess-importtime
Conversation 7 https://github.com/python/cpython/pull/129427
Commits 2 https://github.com/python/cpython/pull/129427/commits
Checks 50 https://github.com/python/cpython/pull/129427/checks
Files changed 2 https://github.com/python/cpython/pull/129427/files
Please reload this pagehttps://github.com/python/cpython/pull/129427/checks
Sign in for the full log viewhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F129427%2Fchecks
gh-118761: Improve import time of subprocess https://github.com/python/cpython/pull/129427/checks#top
Please reload this pagehttps://github.com/python/cpython/pull/129427/checks
Check labels on: pull_request https://github.com/python/cpython/actions/runs/13027931194
DO-NOT-MERGE https://github.com/python/cpython/actions/runs/13027931194/job/36340638739?pr=129427
Unresolved review https://github.com/python/cpython/actions/runs/13027931194/job/36340638995?pr=129427
Lint on: pull_request https://github.com/python/cpython/actions/runs/13027931200
lint https://github.com/python/cpython/actions/runs/13027931200/job/36340638922?pr=129427
Tests on: pull_request https://github.com/python/cpython/actions/runs/13027931212
Change detection / Compute changed files https://github.com/python/cpython/actions/runs/13027931212/job/36340639266?pr=129427
Docs / Docs https://github.com/python/cpython/actions/runs/13027931212/job/36340663495?pr=129427
Docs / Doctest https://github.com/python/cpython/actions/runs/13027931212/job/36340663846?pr=129427
Check if Autoconf files are up to date https://github.com/python/cpython/actions/runs/13027931212/job/36340653749?pr=129427
Check if generated files are up to date https://github.com/python/cpython/actions/runs/13027931212/job/36340654402?pr=129427
Windows / build and test (x64) https://github.com/python/cpython/actions/runs/13027931212/job/36340660415?pr=129427
Windows (free-threading) / build and test (x64) https://github.com/python/cpython/actions/runs/13027931212/job/36340660701?pr=129427
Windows / build and test (arm64) https://github.com/python/cpython/actions/runs/13027931212/job/36340659426?pr=129427
Windows (free-threading) / build and test (arm64) https://github.com/python/cpython/actions/runs/13027931212/job/36340659722?pr=129427
Windows / build and test (Win32) https://github.com/python/cpython/actions/runs/13027931212/job/36340660061?pr=129427
Windows MSI${{ '' }} https://github.com/python/cpython/actions/runs/13027931212/job/36340655875?pr=129427
macOS / build and test (ghcr.io/cirruslabs/macos-runner:sonoma) https://github.com/python/cpython/actions/runs/13027931212/job/36340661002?pr=129427
macOS (free-threading) / build and test (ghcr.io/cirruslabs/macos-runner:sonoma) https://github.com/python/cpython/actions/runs/13027931212/job/36340661313?pr=129427
macOS / build and test (macos-13) https://github.com/python/cpython/actions/runs/13027931212/job/36340661602?pr=129427
Ubuntu / build and test (ubuntu-24.04) https://github.com/python/cpython/actions/runs/13027931212/job/36340661887?pr=129427
Ubuntu / build and test (ubuntu-24.04-arm) https://github.com/python/cpython/actions/runs/13027931212/job/36340662149?pr=129427
Ubuntu (free-threading) / build and test (ubuntu-24.04) https://github.com/python/cpython/actions/runs/13027931212/job/36340662479?pr=129427
Ubuntu (free-threading) / build and test (ubuntu-24.04-arm) https://github.com/python/cpython/actions/runs/13027931212/job/36340662864?pr=129427
Ubuntu (bolt) / build and test (ubuntu-24.04) https://github.com/python/cpython/actions/runs/13027931212/job/36340663198?pr=129427
Ubuntu SSL tests with OpenSSL (ubuntu-24.04, 3.0.15) https://github.com/python/cpython/actions/runs/13027931212/job/36340655446?pr=129427
Ubuntu SSL tests with OpenSSL (ubuntu-24.04, 3.1.7) https://github.com/python/cpython/actions/runs/13027931212/job/36340656699?pr=129427
Ubuntu SSL tests with OpenSSL (ubuntu-24.04, 3.2.3) https://github.com/python/cpython/actions/runs/13027931212/job/36340657030?pr=129427
Ubuntu SSL tests with OpenSSL (ubuntu-24.04, 3.3.2) https://github.com/python/cpython/actions/runs/13027931212/job/36340657331?pr=129427
Ubuntu SSL tests with OpenSSL (ubuntu-24.04, 3.4.0) https://github.com/python/cpython/actions/runs/13027931212/job/36340658036?pr=129427
WASI / build and test https://github.com/python/cpython/actions/runs/13027931212/job/36340659063?pr=129427
Hypothesis tests on Ubuntu https://github.com/python/cpython/actions/runs/13027931212/job/36340656247?pr=129427
Address sanitizer (ubuntu-24.04) https://github.com/python/cpython/actions/runs/13027931212/job/36340655034?pr=129427
Thread sanitizer / Thread sanitizer https://github.com/python/cpython/actions/runs/13027931212/job/36340658285?pr=129427
Thread sanitizer (free-threading) / Thread sanitizer https://github.com/python/cpython/actions/runs/13027931212/job/36340658585?pr=129427
CIFuzz https://github.com/python/cpython/actions/runs/13027931212/job/36340657683?pr=129427
All required checks pass https://github.com/python/cpython/actions/runs/13027931212/job/36342153663?pr=129427
Check labels on: pull_request https://github.com/python/cpython/actions/runs/13027931624
DO-NOT-MERGE https://github.com/python/cpython/actions/runs/13027931624/job/36340639519?pr=129427
Unresolved review https://github.com/python/cpython/actions/runs/13027931624/job/36340639868?pr=129427
Check labels on: pull_request https://github.com/python/cpython/actions/runs/13032377063
DO-NOT-MERGE https://github.com/python/cpython/actions/runs/13032377063/job/36354392401?pr=129427
Unresolved review https://github.com/python/cpython/actions/runs/13032377063/job/36354391970?pr=129427
Check labels on: pull_request https://github.com/python/cpython/actions/runs/13032377289
DO-NOT-MERGE https://github.com/python/cpython/actions/runs/13032377289/job/36354392326?pr=129427
Unresolved review https://github.com/python/cpython/actions/runs/13032377289/job/36354392853?pr=129427
Check labels on: pull_request https://github.com/python/cpython/actions/runs/13035894403
DO-NOT-MERGE https://github.com/python/cpython/actions/runs/13035894403/job/36366118056?pr=129427
Unresolved review https://github.com/python/cpython/actions/runs/13035894403/job/36366118591?pr=129427
Check labels on: pull_request https://github.com/python/cpython/actions/runs/13035894418
DO-NOT-MERGE https://github.com/python/cpython/actions/runs/13035894418/job/36366118039?pr=129427
Unresolved review https://github.com/python/cpython/actions/runs/13035894418/job/36366118538?pr=129427
Check labels on: pull_request https://github.com/python/cpython/actions/runs/13035905782
DO-NOT-MERGE https://github.com/python/cpython/actions/runs/13035905782/job/36366157100?pr=129427
Unresolved review https://github.com/python/cpython/actions/runs/13035905782/job/36366157915?pr=129427
Check labels on: pull_request https://github.com/python/cpython/actions/runs/13035909875
DO-NOT-MERGE https://github.com/python/cpython/actions/runs/13035909875/job/36366172584?pr=129427
Unresolved review https://github.com/python/cpython/actions/runs/13035909875/job/36366172138?pr=129427
Check labels on: pull_request https://github.com/python/cpython/actions/runs/13035912075
DO-NOT-MERGE https://github.com/python/cpython/actions/runs/13035912075/job/36366182058?pr=129427
Unresolved review https://github.com/python/cpython/actions/runs/13035912075/job/36366181247?pr=129427
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.