René's URL Explorer Experiment


Title: bpo-32403: Faster date and datetime constructors by pganssle · Pull Request #4993 · python/cpython · GitHub

Open Graph Title: bpo-32403: Faster date and datetime constructors by pganssle · Pull Request #4993 · python/cpython

X Title: bpo-32403: Faster date and datetime constructors by pganssle · Pull Request #4993 · python/cpython

Description: This fixes bpo-32403 and bpo-32404. The first one is a performance enhancement, the second is a bugfix. Using this script to benchmark the alternate constructors, I see significant improvements in speed across the board (note that since the subclasses don't take the fast path, they are a reasonable proxy for the speed from before this patch). You can see the results on my laptop (using the debug build, not the profiling optimized build) below: Running with N = 10000, k=20 | datetime | DateTimeSubclass ================================================================================= constructor | 1416.5 [1463.9 (±71) ns] | 1494.8 [1569.2 (±119) ns] fromordinal | 1081.5 [1117.2 (±24) ns] | 2180.7 [2357.3 (±279) ns] fromisoformat | 928.8 [962.5 (±34) ns] | 2834.8 [3179.7 (±281) ns] fromtimestamp | 1504.3 [1600.9 (±63) ns] | 3625.1 [3869.6 (±280) ns] utcfromtimestamp | 1178.6 [1281.2 (±172) ns] | 3242.6 [3445.0 (±205) ns] combine | 1060.1 [1111.0 (±73) ns] | 2808.7 [3013.0 (±236) ns] now | 1219.3 [1325.0 (±216) ns] | 3625.5 [3892.7 (±300) ns] today | 4868.5 [5261.0 (±565) ns] | 7189.5 [7663.0 (±436) ns] ================================================================================= | date | DateSubclass ================================================================================= constructor | 974.5 [1010.1 (±39) ns] | 1114.7 [1298.8 (±229) ns] fromordinal | 1059.7 [1109.4 (±59) ns] | 1923.1 [2258.8 (±375) ns] fromisoformat | 817.5 [905.1 (±123) ns] | 1734.1 [2160.8 (±542) ns] fromtimestamp | 1285.4 [1484.7 (±378) ns] | 2363.6 [3038.6 (±783) ns] today | 4551.7 [4976.6 (±584) ns] | 5828.9 [6883.9 (±934) ns] ================================================================================= For comparision, here is the same script run against master: Running with N = 10000, k=20 | datetime | DateTimeSubclass ================================================================================= constructor | 1335.9 [1350.3 (±24) ns] | 1406.0 [1426.9 (±15) ns] fromordinal | 1905.0 [1948.3 (±42) ns] | 2011.5 [2055.4 (±32) ns] fromisoformat | 918.1 [929.3 (±6) ns] | 2660.8 [2707.7 (±25) ns] fromtimestamp | 1570.1 [1611.8 (±28) ns] | 1732.1 [1766.3 (±30) ns] utcfromtimestamp | 1202.7 [1234.5 (±18) ns] | 1334.9 [1371.7 (±26) ns] combine | 2584.9 [2626.3 (±22) ns] | 2722.8 [2759.8 (±25) ns] now | 1317.2 [1338.2 (±9) ns] | 1509.7 [1563.7 (±24) ns] today | 5027.1 [5096.9 (±71) ns] | 5237.6 [5334.9 (±73) ns] ================================================================================= | date | DateSubclass ================================================================================= constructor | 912.8 [928.8 (±15) ns] | 996.4 [1003.9 (±7) ns] fromordinal | 1662.9 [1706.4 (±40) ns] | 1773.6 [1820.7 (±41) ns] fromisoformat | 818.5 [829.0 (±9) ns] | 1630.0 [1743.3 (±289) ns] fromtimestamp | 2155.2 [2213.4 (±41) ns] | 2321.9 [2486.9 (±590) ns] today | 5502.0 [5624.6 (±76) ns] | 5679.8 [5845.4 (±445) ns] ================================================================================= https://bugs.python.org/issue32403

Open Graph Description: This fixes bpo-32403 and bpo-32404. The first one is a performance enhancement, the second is a bugfix. Using this script to benchmark the alternate constructors, I see significant improvements in ...

X Description: This fixes bpo-32403 and bpo-32404. The first one is a performance enhancement, the second is a bugfix. Using this script to benchmark the alternate constructors, I see significant improvements in ...

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

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:4a84032a-2fe9-98af-c61d-f60a938ed12d
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idD6F6:11597D:39E350B:52BB52F:6A4FD86C
html-safe-nonce397ab3301074c609cd04f6a980efe27990bbf3343c936b585e3d2c7fc0888dc2
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENkY2OjExNTk3RDozOUUzNTBCOjUyQkI1MkY6NkE0RkQ4NkMiLCJ2aXNpdG9yX2lkIjoiODExMTMxNzIzMzc1MjMzMjM5NiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac91420789f6fba72c41d00ee01c11807c25a80b41e1ee72eb77b59ca675b6e314
hovercard-subject-tagpull_request:159978497
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/4993/files
twitter:imagehttps://avatars.githubusercontent.com/u/1377457?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/1377457?s=400&v=4
og:image:altThis fixes bpo-32403 and bpo-32404. The first one is a performance enhancement, the second is a bugfix. Using this script to benchmark the alternate constructors, I see significant improvements in ...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None19b98c3d9767bb8a56238a89ff8401d1cbdf3bc5c353799aacf49fe6c76b4b7c
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
release142593e66413bbae27fd485859993597d5a3b104
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python/cpython/pull/4993/files#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F4993%2Ffiles
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
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
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
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/enterprise/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%2F4993%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/4993/files
Reloadhttps://github.com/python/cpython/pull/4993/files
Reloadhttps://github.com/python/cpython/pull/4993/files
Please reload this pagehttps://github.com/python/cpython/pull/4993/files
python https://github.com/python
cpythonhttps://github.com/python/cpython
Please reload this pagehttps://github.com/python/cpython/pull/4993/files
Notifications https://github.com/login?return_to=%2Fpython%2Fcpython
Fork 34.8k https://github.com/login?return_to=%2Fpython%2Fcpython
Star 73.6k 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.3k https://github.com/python/cpython/pulls
Actions https://github.com/python/cpython/actions
Projects https://github.com/python/cpython/projects
Security and quality 0 https://github.com/python/cpython/security
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 and quality 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
abalkinhttps://github.com/abalkin
python:masterhttps://github.com/python/cpython/tree/master
pganssle:faster_datetime_constructorshttps://github.com/pganssle/cpython/tree/faster_datetime_constructors
Conversation 5 https://github.com/python/cpython/pull/4993
Commits 6 https://github.com/python/cpython/pull/4993/commits
Checks 0 https://github.com/python/cpython/pull/4993/checks
Files changed https://github.com/python/cpython/pull/4993/files
Please reload this pagehttps://github.com/python/cpython/pull/4993/files
bpo-32403: Faster date and datetime constructors https://github.com/python/cpython/pull/4993/files#top
Show all changes 6 commits https://github.com/python/cpython/pull/4993/files
5147013 Add tests for date subclass alternate constructors pganssle Dec 21, 2017 https://github.com/python/cpython/pull/4993/commits/5147013cda578044dfa8eff318a424bb1896bd85
5879867 Switch over alternate date constructors to fast path pganssle Dec 21, 2017 https://github.com/python/cpython/pull/4993/commits/587986718781a4156195d413eac1c208a7d64403
2e47897 Switch datetime constructors to fastpath, fix bpo-32404 pganssle Dec 23, 2017 https://github.com/python/cpython/pull/4993/commits/2e47897470eab878649f0675df0d4588f7589e65
a64e967 Add fast path for datetime in date subclass constructor pganssle Dec 23, 2017 https://github.com/python/cpython/pull/4993/commits/a64e9675abf35d07bb38f314b53ddce17aa2b91d
62b52f6 Set fold in constructor in datetime.combine pganssle Dec 23, 2017 https://github.com/python/cpython/pull/4993/commits/62b52f6215e18b4d0f3122f4be6af358c099dfac
b438cbe Add news entries. pganssle Dec 23, 2017 https://github.com/python/cpython/pull/4993/commits/b438cbec71ae203c3ed889f7cd930174ed11090a
Clear filters https://github.com/python/cpython/pull/4993/files
Please reload this pagehttps://github.com/python/cpython/pull/4993/files
Please reload this pagehttps://github.com/python/cpython/pull/4993/files
datetimetester.py https://github.com/python/cpython/pull/4993/files#diff-917d5d1d1423993f37a643afa9f2a2f9caa3c0f91e06c0d7ebea1b879d53b4ef
2017-12-23-14-51-46.bpo-32403.CVFapH.rst https://github.com/python/cpython/pull/4993/files#diff-b244baa8bed136857db1663cf829c9abd0cf48e3a4c47dcc4fe9c4c379c6b82c
2017-12-23-14-54-05.bpo-32404.yJqtlJ.rst https://github.com/python/cpython/pull/4993/files#diff-656b8af3898ecfd09cc5ae903b14ec172978ad9667b719e6b9ca83a43e636a36
_datetimemodule.c https://github.com/python/cpython/pull/4993/files#diff-3ee250e3806e884518fd872e9148baf532de6ec54c1cdb4e7679fbb2869d9c47
Lib/test/datetimetester.pyhttps://github.com/python/cpython/pull/4993/files#diff-917d5d1d1423993f37a643afa9f2a2f9caa3c0f91e06c0d7ebea1b879d53b4ef
View file https://github.com/pganssle/cpython/blob/b438cbec71ae203c3ed889f7cd930174ed11090a/Lib/test/datetimetester.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/4993/{{ revealButtonHref }}
https://github.com/python/cpython/pull/4993/files#diff-917d5d1d1423993f37a643afa9f2a2f9caa3c0f91e06c0d7ebea1b879d53b4ef
https://github.com/python/cpython/pull/4993/files#diff-917d5d1d1423993f37a643afa9f2a2f9caa3c0f91e06c0d7ebea1b879d53b4ef
https://github.com/python/cpython/pull/4993/files#diff-917d5d1d1423993f37a643afa9f2a2f9caa3c0f91e06c0d7ebea1b879d53b4ef
https://github.com/python/cpython/pull/4993/files#diff-917d5d1d1423993f37a643afa9f2a2f9caa3c0f91e06c0d7ebea1b879d53b4ef
Misc/NEWS.d/next/Library/2017-12-23-14-51-46.bpo-32403.CVFapH.rsthttps://github.com/python/cpython/pull/4993/files#diff-b244baa8bed136857db1663cf829c9abd0cf48e3a4c47dcc4fe9c4c379c6b82c
View file https://github.com/pganssle/cpython/blob/b438cbec71ae203c3ed889f7cd930174ed11090a/Misc/NEWS.d/next/Library/2017-12-23-14-51-46.bpo-32403.CVFapH.rst
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/4993/{{ revealButtonHref }}
Misc/NEWS.d/next/Library/2017-12-23-14-54-05.bpo-32404.yJqtlJ.rsthttps://github.com/python/cpython/pull/4993/files#diff-656b8af3898ecfd09cc5ae903b14ec172978ad9667b719e6b9ca83a43e636a36
View file https://github.com/pganssle/cpython/blob/b438cbec71ae203c3ed889f7cd930174ed11090a/Misc/NEWS.d/next/Library/2017-12-23-14-54-05.bpo-32404.yJqtlJ.rst
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/4993/{{ revealButtonHref }}
Modules/_datetimemodule.chttps://github.com/python/cpython/pull/4993/files#diff-3ee250e3806e884518fd872e9148baf532de6ec54c1cdb4e7679fbb2869d9c47
View file https://github.com/pganssle/cpython/blob/b438cbec71ae203c3ed889f7cd930174ed11090a/Modules/_datetimemodule.c
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/4993/{{ revealButtonHref }}
https://github.com/python/cpython/pull/4993/files#diff-3ee250e3806e884518fd872e9148baf532de6ec54c1cdb4e7679fbb2869d9c47
https://github.com/python/cpython/pull/4993/files#diff-3ee250e3806e884518fd872e9148baf532de6ec54c1cdb4e7679fbb2869d9c47
https://github.com/python/cpython/pull/4993/files#diff-3ee250e3806e884518fd872e9148baf532de6ec54c1cdb4e7679fbb2869d9c47
https://github.com/python/cpython/pull/4993/files#diff-3ee250e3806e884518fd872e9148baf532de6ec54c1cdb4e7679fbb2869d9c47
https://github.com/python/cpython/pull/4993/files#diff-3ee250e3806e884518fd872e9148baf532de6ec54c1cdb4e7679fbb2869d9c47
https://github.com/python/cpython/pull/4993/files#diff-3ee250e3806e884518fd872e9148baf532de6ec54c1cdb4e7679fbb2869d9c47
https://github.com/python/cpython/pull/4993/files#diff-3ee250e3806e884518fd872e9148baf532de6ec54c1cdb4e7679fbb2869d9c47
https://github.com/python/cpython/pull/4993/files#diff-3ee250e3806e884518fd872e9148baf532de6ec54c1cdb4e7679fbb2869d9c47
https://github.com/python/cpython/pull/4993/files#diff-3ee250e3806e884518fd872e9148baf532de6ec54c1cdb4e7679fbb2869d9c47
https://github.com/python/cpython/pull/4993/files#diff-3ee250e3806e884518fd872e9148baf532de6ec54c1cdb4e7679fbb2869d9c47
https://github.com/python/cpython/pull/4993/files#diff-3ee250e3806e884518fd872e9148baf532de6ec54c1cdb4e7679fbb2869d9c47
https://github.com/python/cpython/pull/4993/files#diff-3ee250e3806e884518fd872e9148baf532de6ec54c1cdb4e7679fbb2869d9c47
https://github.com/python/cpython/pull/4993/files#diff-3ee250e3806e884518fd872e9148baf532de6ec54c1cdb4e7679fbb2869d9c47
https://github.com/python/cpython/pull/4993/files#diff-3ee250e3806e884518fd872e9148baf532de6ec54c1cdb4e7679fbb2869d9c47
https://github.com/python/cpython/pull/4993/files#diff-3ee250e3806e884518fd872e9148baf532de6ec54c1cdb4e7679fbb2869d9c47
https://github.com/python/cpython/pull/4993/files#diff-3ee250e3806e884518fd872e9148baf532de6ec54c1cdb4e7679fbb2869d9c47
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.