perf: Prefer datetime.fromisoformat over dateutil.parse in Python 3.11+ #657
Merged
bednar merged 3 commits intoinfluxdata:masterfrom May 20, 2024
Merged
Conversation
|
Codecov ReportAttention: Patch coverage is
❗ Your organization needs to install the Codecov 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 to
9232a81
Compare
9232a81 to
46f4f7e
Compare
bednar
approved these changes
May 20, 2024
Contributor
bednar
left a comment
There was a problem hiding this comment.
@n-thumann, thank you for your fantastic PR! 👍
LGTM 🚀
Merged
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed Changes
This PR changes the behavior of
get_date_helperto preferdatetime.datetime.fromisoformatoverdateutil.parserin Python 3.11 or higher.According to https://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
ciso8601installed, respectively. On Python 3.11 I've got ~2,5s and ~2,6s without and withciso8601installed, respectively.Because
cisois 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 testscompletes successfully