influxdata / influxdb-client-python

InfluxDB 2.0 python client
https://influxdb-client.readthedocs.io/en/stable/
MIT License
706 stars 185 forks source link

perf: Prefer datetime.fromisoformat over dateutil.parse in Python 3.11+ #657

Closed n-thumann closed 3 months ago

n-thumann commented 3 months ago

Proposed Changes

This PR changes the behavior of get_date_helper to prefer datetime.datetime.fromisoformat over dateutil.parser in 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 with ciso8601: 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 with ciso8601 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

codecov-commenter commented 3 months ago

:warning: Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 90.40%. Comparing base (d2393e0) to head (b97b611). Report is 9 commits behind head on master.

Files Patch % Lines
influxdb_client/client/util/date_utils.py 75.00% 1 Missing :warning:

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files ```diff @@ 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 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.