- Notifications
You must be signed in to change notification settings - Fork186
perf: Prefer datetime.fromisoformat over dateutil.parse in Python 3.11+#657
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
perf: Prefer datetime.fromisoformat over dateutil.parse in Python 3.11+#657
Uh oh!
There was an error while loading.Please reload this page.
Conversation
codecov-commenter commentedMay 18, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Codecov ReportAttention: Patch coverage is
❗ Your organization needs to install theCodecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@## master #657 +/- ##==========================================- Coverage 90.42% 90.40% -0.03%========================================== Files 39 39 Lines 3510 3513 +3 ==========================================+ Hits 3174 3176 +2- Misses 336 337 +1 ☔ View full report in Codecov by Sentry. |
91eeb51
to9232a81
Compare9232a81
to46f4f7e
CompareThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
@n-thumann, thank you for your fantastic PR! 👍
LGTM 🚀
73849e7
intoinfluxdata:masterUh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Proposed Changes
This PR changes the behavior of
get_date_helper
to preferdatetime.datetime.fromisoformat
overdateutil.parser
in Python 3.11 or higher.According tohttps://github.com/closeio/ciso8601/blob/b17984f5b4c6db0ef596b4d31456c8a39ae278ee/why_ciso8601.md,
Since Python 3.11+, the performance of cPython's datetime.fromisoformat is now very good
. I did some quick testing and it seems to be on a par withciso8601
:On Python 3.10 I've got ~37,5s and ~3,5s without and with
ciso8601
installed, respectively. On Python 3.11 I've got ~2,5s and ~2,6s without and withciso8601
installed, respectively.Because
ciso
is no dependency, but an extra, not all users (including me) installed it. With this PR these users will get a better out-of-the-box performance for Python 3.11+ users.Checklist
pytest tests
completes successfully