René's URL Explorer Experiment


Title: bpo-15873: Implement [date][time].fromisoformat by pganssle · Pull Request #4699 · python/cpython · GitHub

Open Graph Title: bpo-15873: Implement [date][time].fromisoformat by pganssle · Pull Request #4699 · python/cpython

X Title: bpo-15873: Implement [date][time].fromisoformat by pganssle · Pull Request #4699 · python/cpython

Description: Per discussion on the python-dev mailing list, this is a C implementation of fromisoformat as alternate constructors for datetime, date and time, resolving this issue. If it is deemed desirable, it can be extended later to cover all ISO-8601 datetime strings, but I believe the consensus so far is to have a minimum implementation that only covers the outputs of datetime.isoformat(). One thing I'd like to call attention to is that my profiling seems to indicate that in the common case (i.e. not calling this from a subclass), using the C API directly is much faster than going through PyObject_CallFunction. Here is a profiling script: from datetime import datetime from datetime import timezone, timedelta from timeit import default_timer as timer N = 100000 tzi = timezone(timedelta(hours=4)) tzi = None comps = (2014, 3, 25, 4, 17, 30, 204300, tzi) dt = datetime(*comps) s = timer() for i in range(N): dt_c = datetime(2014, 3, 25, 4, 17, 30, 241300, tzinfo=tzi) e = timer() tt = 1000000000 * (e - s) / N dtstr = dt.isoformat() s = timer() for i in range(N): dt_fi = datetime.fromisoformat(dtstr) e = timer() tt2 = 1000000000 * (e - s) / N print('datetime constructor: {:0.1f}ns'.format(tt)) print('fromisoformat: {:0.1f}ns'.format(tt2)) Result on my laptop: (tzi is None): datetime constructor: 2294.1ns fromisoformat: 944.5ns (tzi = timezone(timedelta(hours=4))) datetime constructor: 2229.1ns fromisoformat: 1400.5ns If there's no particularly pressing reason why all the other alternate constructors universally go through the main constructor call, I could write a small function or macro that would take the fast path if available and use it for all the alternate constructors. CC @abalkin @mariocj89 https://bugs.python.org/issue15873

Open Graph Description: Per discussion on the python-dev mailing list, this is a C implementation of fromisoformat as alternate constructors for datetime, date and time, resolving this issue. If it is deemed desirable, it...

X Description: Per discussion on the python-dev mailing list, this is a C implementation of fromisoformat as alternate constructors for datetime, date and time, resolving this issue. If it is deemed desirable, it...

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

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:d02b8afd-98e4-50d9-b6ff-90e8db920f50
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idD970:5CED0:E30E:133A4:6A4D24EA
html-safe-nonce5147c031afc85c5096bcb5a67cf077b39a7f4d0bd20d77bc7911d720ef0a9635
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEOTcwOjVDRUQwOkUzMEU6MTMzQTQ6NkE0RDI0RUEiLCJ2aXNpdG9yX2lkIjoiNDA1MjYzOTcwNjczMDI3NjA3NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmace14a577ddb5954913b357b637a2f16ee2f76628d1cee17b8378d0d0324a763ac
hovercard-subject-tagpull_request:156259816
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/4699/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:altPer discussion on the python-dev mailing list, this is a C implementation of fromisoformat as alternate constructors for datetime, date and time, resolving this issue. If it is deemed desirable, it...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None92571a8944142227b7e19cd10918b1ddd06e5066c1ad5bc7e4769cf6140a87e6
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
release93f17a978ee60bc4668e1d7b90e6bd2d622261fd
ui-targetcanary-2
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python/cpython/pull/4699/files#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F4699%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/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/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/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%2F4699%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/4699/files
Reloadhttps://github.com/python/cpython/pull/4699/files
Reloadhttps://github.com/python/cpython/pull/4699/files
Please reload this pagehttps://github.com/python/cpython/pull/4699/files
python https://github.com/python
cpythonhttps://github.com/python/cpython
Please reload this pagehttps://github.com/python/cpython/pull/4699/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:from_isoformathttps://github.com/pganssle/cpython/tree/from_isoformat
Conversation 54 https://github.com/python/cpython/pull/4699
Commits 21 https://github.com/python/cpython/pull/4699/commits
Checks 0 https://github.com/python/cpython/pull/4699/checks
Files changed https://github.com/python/cpython/pull/4699/files
Please reload this pagehttps://github.com/python/cpython/pull/4699/files
bpo-15873: Implement [date][time].fromisoformat https://github.com/python/cpython/pull/4699/files#top
Show all changes 21 commits https://github.com/python/cpython/pull/4699/files
b451a83 Add C implementation of date.fromisoformat pganssle Dec 1, 2017 https://github.com/python/cpython/pull/4699/commits/b451a83620d12024fe3e0d78cb74d3f9a6204e49
4ccef0a Add python implementation of date.fromisoformat pganssle Dec 1, 2017 https://github.com/python/cpython/pull/4699/commits/4ccef0a380a839e66171ec5e4b2f0eef2cd51773
13e8e48 Add tests for date.fromisoformat pganssle Dec 1, 2017 https://github.com/python/cpython/pull/4699/commits/13e8e48bb438281f1fe88882b1bd4a40af318771
6fa5c55 Implement C version of datetime.fromisoformat pganssle Dec 2, 2017 https://github.com/python/cpython/pull/4699/commits/6fa5c557d9ff8276aa8f35fbfaf3a19e522a95a2
0d44220 Add initial test suite for C-only datetime.fromisoformat pganssle Dec 2, 2017 https://github.com/python/cpython/pull/4699/commits/0d44220dc96d1c06291c76cd6a49913868d984ee
327d0fc Add C implementation of time.fromisoformat() pganssle Dec 4, 2017 https://github.com/python/cpython/pull/4699/commits/327d0fc2bca061f596212e913671d0c653963be2
52b2175 Add tests for time.isoformat() pganssle Dec 4, 2017 https://github.com/python/cpython/pull/4699/commits/52b2175918d4426ca8cbf70d80b018afdac19a58
f1b78af Add pure python implementation of time.fromisoformat() pganssle Dec 4, 2017 https://github.com/python/cpython/pull/4699/commits/f1b78af608d1275058badf4a3eb18837148e1faa
aeaa9ca Add tests for pure python time.fromisoformat() pganssle Dec 4, 2017 https://github.com/python/cpython/pull/4699/commits/aeaa9ca2a657d2dc98b0bd168b784ab0707d36f0
094ccf4 Add pure python implementation of datetime.fromisoformat pganssle Dec 4, 2017 https://github.com/python/cpython/pull/4699/commits/094ccf4368118af8e8f4867278d93ff85db3aa5f
2a8120d Enable tests for pure python datetime.fromisoformat pganssle Dec 4, 2017 https://github.com/python/cpython/pull/4699/commits/2a8120d21b7f872d12120563746f97deaad3bd09
af9e6d0 Add documentation for [date][time].fromisoformat() pganssle Dec 4, 2017 https://github.com/python/cpython/pull/4699/commits/af9e6d02acb5db4112fa75bfc9450a3f521d5e65
cf802af Consolidate helper functions into parse_digits pganssle Dec 5, 2017 https://github.com/python/cpython/pull/4699/commits/cf802aff7492781714eb2b83854dfe79ccf71561
626d239 Refactor datetime.isoformat round trip tests pganssle Dec 5, 2017 https://github.com/python/cpython/pull/4699/commits/626d239b911565825cf47a683425506c51aed731
7c771e7 Refactor C code for PEP 7 pganssle Dec 5, 2017 https://github.com/python/cpython/pull/4699/commits/7c771e73c411635394908ebe904803415337a7ea
8fbd752 Add support for seconds in fromisoformat offsets pganssle Dec 6, 2017 https://github.com/python/cpython/pull/4699/commits/8fbd75224709d8f458be58615f31ea14b4f97e3e
4d55e05 Fix pure python implementation of isoformat() for sub-second zones pganssle Dec 9, 2017 https://github.com/python/cpython/pull/4699/commits/4d55e050a41b643b3c6ddf32688d3859386c29aa
5a233fb Add support for subsecond offsets to fromisoformat pganssle Dec 9, 2017 https://github.com/python/cpython/pull/4699/commits/5a233fb42c9c9e4b905d62a5c6f250752e74e14b
9fa91db Fix documentation and pure python error catching in fromisoformat pganssle Dec 18, 2017 https://github.com/python/cpython/pull/4699/commits/9fa91db1b718d4a8377eab3afccd16c717b5085b
ffdb2af Drop unsupported sep parameter in _tzstr pganssle Dec 18, 2017 https://github.com/python/cpython/pull/4699/commits/ffdb2afbca78ebcf7adbf42537c7d93cf1d0bb50
18a5fa8 Add test for ambiguous isoformat strings pganssle Dec 18, 2017 https://github.com/python/cpython/pull/4699/commits/18a5fa84b49a56acee0c9f9ef4773b786759d1c3
Clear filters https://github.com/python/cpython/pull/4699/files
Please reload this pagehttps://github.com/python/cpython/pull/4699/files
Please reload this pagehttps://github.com/python/cpython/pull/4699/files
datetime.rst https://github.com/python/cpython/pull/4699/files#diff-591e6aa401ebcd90f71f28b517b3d4437ba293920787df9ed06e037af0b07175
datetime.py https://github.com/python/cpython/pull/4699/files#diff-2a8962dcecb109859cedd81ddc5729bea57d156e0947cb8413f99781a0860fd1
datetimetester.py https://github.com/python/cpython/pull/4699/files#diff-917d5d1d1423993f37a643afa9f2a2f9caa3c0f91e06c0d7ebea1b879d53b4ef
2017-12-04-17-41-40.bpo-15873.-T4TRK.rst https://github.com/python/cpython/pull/4699/files#diff-67c262f6c771f2f2f9f477b7cc2405a176f2e1c271750a2ff4bd52aa61083f71
_datetimemodule.c https://github.com/python/cpython/pull/4699/files#diff-3ee250e3806e884518fd872e9148baf532de6ec54c1cdb4e7679fbb2869d9c47
Doc/library/datetime.rsthttps://github.com/python/cpython/pull/4699/files#diff-591e6aa401ebcd90f71f28b517b3d4437ba293920787df9ed06e037af0b07175
View file https://github.com/pganssle/cpython/blob/18a5fa84b49a56acee0c9f9ef4773b786759d1c3/Doc/library/datetime.rst
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/4699/{{ revealButtonHref }}
https://github.com/python/cpython/pull/4699/files#diff-591e6aa401ebcd90f71f28b517b3d4437ba293920787df9ed06e037af0b07175
https://github.com/python/cpython/pull/4699/files#diff-591e6aa401ebcd90f71f28b517b3d4437ba293920787df9ed06e037af0b07175
https://github.com/python/cpython/pull/4699/files#diff-591e6aa401ebcd90f71f28b517b3d4437ba293920787df9ed06e037af0b07175
https://github.com/python/cpython/pull/4699/files#diff-591e6aa401ebcd90f71f28b517b3d4437ba293920787df9ed06e037af0b07175
https://github.com/python/cpython/pull/4699/files#diff-591e6aa401ebcd90f71f28b517b3d4437ba293920787df9ed06e037af0b07175
https://github.com/python/cpython/pull/4699/files#diff-591e6aa401ebcd90f71f28b517b3d4437ba293920787df9ed06e037af0b07175
https://github.com/python/cpython/pull/4699/files#diff-591e6aa401ebcd90f71f28b517b3d4437ba293920787df9ed06e037af0b07175
https://github.com/python/cpython/pull/4699/files#diff-591e6aa401ebcd90f71f28b517b3d4437ba293920787df9ed06e037af0b07175
Lib/datetime.pyhttps://github.com/python/cpython/pull/4699/files#diff-2a8962dcecb109859cedd81ddc5729bea57d156e0947cb8413f99781a0860fd1
View file https://github.com/pganssle/cpython/blob/18a5fa84b49a56acee0c9f9ef4773b786759d1c3/Lib/datetime.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/4699/{{ revealButtonHref }}
https://github.com/python/cpython/pull/4699/files#diff-2a8962dcecb109859cedd81ddc5729bea57d156e0947cb8413f99781a0860fd1
https://github.com/python/cpython/pull/4699/files#diff-2a8962dcecb109859cedd81ddc5729bea57d156e0947cb8413f99781a0860fd1
https://github.com/python/cpython/pull/4699/files#diff-2a8962dcecb109859cedd81ddc5729bea57d156e0947cb8413f99781a0860fd1
https://github.com/python/cpython/pull/4699/files#diff-2a8962dcecb109859cedd81ddc5729bea57d156e0947cb8413f99781a0860fd1
https://github.com/python/cpython/pull/4699/files#diff-2a8962dcecb109859cedd81ddc5729bea57d156e0947cb8413f99781a0860fd1
https://github.com/python/cpython/pull/4699/files#diff-2a8962dcecb109859cedd81ddc5729bea57d156e0947cb8413f99781a0860fd1
https://github.com/python/cpython/pull/4699/files#diff-2a8962dcecb109859cedd81ddc5729bea57d156e0947cb8413f99781a0860fd1
https://github.com/python/cpython/pull/4699/files#diff-2a8962dcecb109859cedd81ddc5729bea57d156e0947cb8413f99781a0860fd1
https://github.com/python/cpython/pull/4699/files#diff-2a8962dcecb109859cedd81ddc5729bea57d156e0947cb8413f99781a0860fd1
pgansslehttps://github.com/pganssle
Dec 5, 2017https://github.com/python/cpython/pull/4699/files#r154831594
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/python/cpython/pull/4699/files
https://github.com/python/cpython/pull/4699/files#diff-2a8962dcecb109859cedd81ddc5729bea57d156e0947cb8413f99781a0860fd1
https://github.com/python/cpython/pull/4699/files#diff-2a8962dcecb109859cedd81ddc5729bea57d156e0947cb8413f99781a0860fd1
https://github.com/python/cpython/pull/4699/files#diff-2a8962dcecb109859cedd81ddc5729bea57d156e0947cb8413f99781a0860fd1
https://github.com/python/cpython/pull/4699/files#diff-2a8962dcecb109859cedd81ddc5729bea57d156e0947cb8413f99781a0860fd1
https://github.com/python/cpython/pull/4699/files#diff-2a8962dcecb109859cedd81ddc5729bea57d156e0947cb8413f99781a0860fd1
https://github.com/python/cpython/pull/4699/files#diff-2a8962dcecb109859cedd81ddc5729bea57d156e0947cb8413f99781a0860fd1
https://github.com/python/cpython/pull/4699/files#diff-2a8962dcecb109859cedd81ddc5729bea57d156e0947cb8413f99781a0860fd1
Please reload this pagehttps://github.com/python/cpython/pull/4699/files
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.