Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify timestamp parsing #3063

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open

Simplify timestamp parsing #3063

wants to merge 3 commits into from

Conversation

akx
Copy link
Contributor

@akx akx commented Nov 15, 2023

As mentioned in #2972 (comment):

_parse_timestamp_with_tzinfo() already attempts to do fromtimestamp parsing; not much point in doing that work twice for timestamp-esque strings (and failing in the cases described in #2972).

In the subsequent commits, this PR also cleans up remaining seemingly Useless Use of tzlocal.

@codecov-commenter
Copy link

codecov-commenter commented Nov 15, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.15%. Comparing base (8fd0160) to head (3575969).
Report is 120 commits behind head on develop.

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

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #3063   +/-   ##
========================================
  Coverage    93.14%   93.15%           
========================================
  Files           66       66           
  Lines        14237    14219   -18     
========================================
- Hits         13261    13245   -16     
+ Misses         976      974    -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@akx akx marked this pull request as draft November 15, 2023 07:23
@akx
Copy link
Contributor Author

akx commented Nov 15, 2023

@nateprewitt I have some tests you seem to have added for #1987 failing with this (hence a draft), but you might have some context to help here: Why do we need tzlocal or tzwinlocal in the first place?

parse_timestamp doesn't necessarily guarantee the returned datetime should have any tzinfo attached, though the tests seem to always assume it's UTC, and practically, parsing any timestamp off the wire does prescribe a timezone in some way (GMT for RFC822, Z for ISO8601).

Might I be right in guessing the tzlocal/tzwinlocal stuff could actually be all removed in favor of _epoch_seconds_to_datetime's arithmetics?

@akx akx changed the title Use _epoch_seconds_to_datetime in _parse_timestamp_with_tzinfo Simplify timestamp parsing Nov 15, 2023
@akx
Copy link
Contributor Author

akx commented Nov 15, 2023

... to follow up on my last comment: one way to find out! (Remaining) tests seem to pass fine, and this is about 28% faster for a benchmark of common values passed in to this function.

(I have another commit – for a future PR – to stack on this that will further increase parsing performance for common cases about 23x compared to develop.)

@akx
Copy link
Contributor Author

akx commented Nov 28, 2023

(Gentle review nudge, @nateprewitt? 😄)

@akx
Copy link
Contributor Author

akx commented Jan 10, 2024

Another nudge, @nateprewitt... I noticed you'd said

we still have some concerns around the original windows issue that lead to that PR. It's likely safe to clean up as you've suggested but we'll need to do some manual testing first.

in #3062 – anything I can do to help things along?

@akx
Copy link
Contributor Author

akx commented Feb 16, 2024

Sorry for Yet Another Ping, @nateprewitt 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants