René's URL Explorer Experiment


Title: gh-103793: Defer formatting task name by itamaro · Pull Request #103767 · python/cpython · GitHub

Open Graph Title: gh-103793: Defer formatting task name by itamaro · Pull Request #103767 · python/cpython

X Title: gh-103793: Defer formatting task name by itamaro · Pull Request #103767 · python/cpython

Description: The default task name is Task- (if no name is passed in during Task creation). This is initialized in Task.__init__ (C impl) using string formatting, which can be quite slow. Actually using the task name in real world code is not very common, so this is wasted init. Let's defer this string formatting to the first time the name is read (in get_name impl), so we don't need to pay the string formatting cost if the task name is never read. Fixes gh-103793 performance analysis in a full run of pyperformance, this is 1.00x faster overall, and up to 5% faster on async benchmarks. full report in this gist.

Open Graph Description: The default task name is Task-<counter> (if no name is passed in during Task creation). This is initialized in Task.__init__ (C impl) using string formatting, which can be quite slow. Actuall...

X Description: The default task name is Task-&lt;counter&gt; (if no name is passed in during Task creation). This is initialized in Task.__init__ (C impl) using string formatting, which can be quite slow....

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

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:7a48286c-22d9-3657-d68d-b5815f496467
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idD880:97651:437D9B:5AE5C6:6969D219
html-safe-nonce3c787bf1a8a34c54ce25b8d36a428d9459d368f5809664bc6ca859cc5e9160d4
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEODgwOjk3NjUxOjQzN0Q5Qjo1QUU1QzY6Njk2OUQyMTkiLCJ2aXNpdG9yX2lkIjoiMzI5NjYyNzk3NTQ1MTY5MzU5NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac9be5282537f14d63016a4ee5dee7550daa750949e653c7838d161202561fa7c5
hovercard-subject-tagpull_request:1325791834
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/python/cpython/pull/103767/files
twitter:imagehttps://avatars.githubusercontent.com/u/290943?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/290943?s=400&v=4
og:image:altThe default task name is Task-<counter> (if no name is passed in during Task creation). This is initialized in Task.__init__ (C impl) using string formatting, which can be quite slow. Actuall...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
Noneacedec8b5f975d9e3d494ddd8f949b0b8a0de59d393901e26f73df9dcba80056
turbo-cache-controlno-preview
diff-viewunified
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
disable-turbotrue
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/103767/files#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F103767%2Ffiles
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%2F103767%2Ffiles
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%2Ffiles&source=header-repo&source_repo=python%2Fcpython
Reloadhttps://github.com/python/cpython/pull/103767/files
Reloadhttps://github.com/python/cpython/pull/103767/files
Reloadhttps://github.com/python/cpython/pull/103767/files
python https://github.com/python
cpythonhttps://github.com/python/cpython
Please reload this pagehttps://github.com/python/cpython/pull/103767/files
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/103767/files
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
gvanrossumhttps://github.com/gvanrossum
python:mainhttps://github.com/python/cpython/tree/main
itamaro:defer-task-name-formattinghttps://github.com/itamaro/cpython/tree/defer-task-name-formatting
Conversation 22 https://github.com/python/cpython/pull/103767
Commits 14 https://github.com/python/cpython/pull/103767/commits
Checks 0 https://github.com/python/cpython/pull/103767/checks
Files changed https://github.com/python/cpython/pull/103767/files
Please reload this pagehttps://github.com/python/cpython/pull/103767/files
gh-103793: Defer formatting task name https://github.com/python/cpython/pull/103767/files#top
Show all changes 14 commits https://github.com/python/cpython/pull/103767/files
e8353cc Defer formatting task name itamaro Apr 24, 2023 https://github.com/python/cpython/pull/103767/commits/e8353cca99e57427b8d86295e249a313331f7c58
1822ff8 Defer task name formatting also in Python Task impl itamaro Apr 24, 2023 https://github.com/python/cpython/pull/103767/commits/1822ff8355231ccbaf226683a16e3a06af6afb84
74d0084 Add NEWS and whatsnew entries itamaro Apr 24, 2023 https://github.com/python/cpython/pull/103767/commits/74d0084b7267601afecb24e3737516db27d914b1
dbc7047 Merge branch 'main' into defer-task-name-formatting ambv Apr 25, 2023 https://github.com/python/cpython/pull/103767/commits/dbc7047076138ca098dca1ec6c55d8c4e988656f
2bb6c1e Merge branch 'main' into defer-task-name-formatting itamaro Apr 25, 2023 https://github.com/python/cpython/pull/103767/commits/2bb6c1e2823c05df677b611562ad03f6f24555d2
2efd376 replace storing the task counter on task construction with just getti… itamaro Apr 25, 2023 https://github.com/python/cpython/pull/103767/commits/2efd376a739946c5fd9d2902f04634f21763c9a7
6cb321b Merge branch 'defer-task-name-formatting' of github.com:itamaro/cpyth… itamaro Apr 25, 2023 https://github.com/python/cpython/pull/103767/commits/6cb321bf4b7d59b0c99f7d0f86c18d3b18902d02
7cde290 remove redundant return itamaro Apr 25, 2023 https://github.com/python/cpython/pull/103767/commits/7cde29001edba17e59f51a4f24e336a20ac7210c
4b50646 Merge branch 'main' into defer-task-name-formatting itamaro Apr 25, 2023 https://github.com/python/cpython/pull/103767/commits/4b5064647bc4804d49fd0c0ce581c44877858698
a155190 revert changes to python version itamaro Apr 25, 2023 https://github.com/python/cpython/pull/103767/commits/a155190e96b1666683c45cc716915d52f32a1e25
fb2bd7f pass error up if PyUnicode_FromFormat returns NULL itamaro Apr 25, 2023 https://github.com/python/cpython/pull/103767/commits/fb2bd7fbf086b633e8b0fcc49dc3f24ec6b7951c
41e9a59 Switch back to original "assign task number at construction" but stor… itamaro Apr 26, 2023 https://github.com/python/cpython/pull/103767/commits/41e9a59cc85b7ece7db3ede35dc65df336c0f845
712edf9 Add test that using an explicit PyLong as task name does not accident… itamaro Apr 26, 2023 https://github.com/python/cpython/pull/103767/commits/712edf9ab5faf83f5600081548611efed87b1a93
592d44b Merge branch 'main' into defer-task-name-formatting itamaro Apr 26, 2023 https://github.com/python/cpython/pull/103767/commits/592d44b3d0b889abc20233e9f44dec277574a867
Clear filters https://github.com/python/cpython/pull/103767/files
Please reload this pagehttps://github.com/python/cpython/pull/103767/files
Please reload this pagehttps://github.com/python/cpython/pull/103767/files
3.12.rst https://github.com/python/cpython/pull/103767/files#diff-0f2c1763c64530268325a0ee2dfaa4f5d555c4ac27deb78bd77102c8ce1b886b
test_tasks.py https://github.com/python/cpython/pull/103767/files#diff-ef1c83c981ac721906ba3b05e123351be23dcfb59e92d0aeb6f4033db9cdd8c8
2023-04-24-14-38-16.gh-issue-103793.kqoH6Q.rst https://github.com/python/cpython/pull/103767/files#diff-1250d6930c2ccd63a15535df6696b7ec81bab40f6386e531db4dd5f3f72aab07
_asynciomodule.c https://github.com/python/cpython/pull/103767/files#diff-6bd9e39980b88a721d902bcd915bbb3f24762f7f253430c45e52c42a2c5afd01
https://github.com/python/cpython/blob/main/.github/CODEOWNERS#L114
Doc/whatsnew/3.12.rsthttps://github.com/python/cpython/pull/103767/files#diff-0f2c1763c64530268325a0ee2dfaa4f5d555c4ac27deb78bd77102c8ce1b886b
View file https://github.com/itamaro/cpython/blob/592d44b3d0b889abc20233e9f44dec277574a867/Doc/whatsnew/3.12.rst
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/103767/{{ revealButtonHref }}
https://github.com/python/cpython/pull/103767/files#diff-0f2c1763c64530268325a0ee2dfaa4f5d555c4ac27deb78bd77102c8ce1b886b
https://github.com/python/cpython/pull/103767/files#diff-0f2c1763c64530268325a0ee2dfaa4f5d555c4ac27deb78bd77102c8ce1b886b
https://github.com/python/cpython/blob/main/.github/CODEOWNERS#L370
Lib/test/test_asyncio/test_tasks.pyhttps://github.com/python/cpython/pull/103767/files#diff-ef1c83c981ac721906ba3b05e123351be23dcfb59e92d0aeb6f4033db9cdd8c8
View file https://github.com/itamaro/cpython/blob/592d44b3d0b889abc20233e9f44dec277574a867/Lib/test/test_asyncio/test_tasks.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/103767/{{ revealButtonHref }}
https://github.com/python/cpython/pull/103767/files#diff-ef1c83c981ac721906ba3b05e123351be23dcfb59e92d0aeb6f4033db9cdd8c8
https://github.com/python/cpython/pull/103767/files#diff-ef1c83c981ac721906ba3b05e123351be23dcfb59e92d0aeb6f4033db9cdd8c8
Misc/NEWS.d/next/Core and Builtins/2023-04-24-14-38-16.gh-issue-103793.kqoH6Q.rsthttps://github.com/python/cpython/pull/103767/files#diff-1250d6930c2ccd63a15535df6696b7ec81bab40f6386e531db4dd5f3f72aab07
View file https://github.com/itamaro/cpython/blob/592d44b3d0b889abc20233e9f44dec277574a867/Misc/NEWS.d/next/Core%20and%20Builtins/2023-04-24-14-38-16.gh-issue-103793.kqoH6Q.rst
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/103767/{{ revealButtonHref }}
https://github.com/python/cpython/blob/main/.github/CODEOWNERS#L371
Modules/_asynciomodule.chttps://github.com/python/cpython/pull/103767/files#diff-6bd9e39980b88a721d902bcd915bbb3f24762f7f253430c45e52c42a2c5afd01
View file https://github.com/itamaro/cpython/blob/592d44b3d0b889abc20233e9f44dec277574a867/Modules/_asynciomodule.c
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/103767/{{ revealButtonHref }}
https://github.com/python/cpython/pull/103767/files#diff-6bd9e39980b88a721d902bcd915bbb3f24762f7f253430c45e52c42a2c5afd01
https://github.com/python/cpython/pull/103767/files#diff-6bd9e39980b88a721d902bcd915bbb3f24762f7f253430c45e52c42a2c5afd01
https://github.com/python/cpython/pull/103767/files#diff-6bd9e39980b88a721d902bcd915bbb3f24762f7f253430c45e52c42a2c5afd01
https://github.com/python/cpython/pull/103767/files#diff-6bd9e39980b88a721d902bcd915bbb3f24762f7f253430c45e52c42a2c5afd01
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.