-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
cleanup; use timedelta instead of relativedelta where possible #18183
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
Conversation
Hello @jbrockmendel! Thanks for updating the PR. Cheers ! There are no PEP8 issues in this Pull Request. 🍻 Comment last updated on November 09, 2017 at 04:50 Hours UTC |
Codecov Report
@@ Coverage Diff @@
## master #18183 +/- ##
==========================================
- Coverage 91.42% 91.4% -0.02%
==========================================
Files 163 163
Lines 50068 50065 -3
==========================================
- Hits 45776 45764 -12
- Misses 4292 4301 +9
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #18183 +/- ##
==========================================
- Coverage 91.42% 91.4% -0.02%
==========================================
Files 163 163
Lines 50068 50065 -3
==========================================
- Hits 45776 45764 -12
- Misses 4292 4301 +9
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #18183 +/- ##
==========================================
- Coverage 91.42% 91.4% -0.02%
==========================================
Files 163 163
Lines 50068 50065 -3
==========================================
- Hits 45776 45764 -12
- Misses 4292 4301 +9
Continue to review full report at Codecov.
|
Question (it has been a long time I worked with relativedeltas): in the non-replace case (so when using plural kwargs to relativedelta), is addition with relativedelta then always fully equivalent to addition of a timedelta? |
@@ -2382,7 +2379,7 @@ def apply(self, other): | |||
qtr_lens = self.get_weeks(other + self._offset) | |||
|
|||
for weeks in qtr_lens: | |||
start += relativedelta(weeks=weeks) |
There 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.
i would leave the weeks, not real well tested for timedelta; relativedelta may be more intelligent here
There 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.
i would leave the weeks, not real well tested for timedelta
Not sure I understand. You mean the stdlib timedelta isn't well-tested?
There 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.
relativedelta may be more intelligent here
The relativedelta constructor just adds weeks*7
to the days
kwarg.
The fact that relativedelta's behavior is more obscure is part of why this change is helpful. (Also the perf improvement is a free lunch)
For everything weeks and shorter, yes. Months and years have more complicated behavior.
In the pertinent case,
|
Working on fixes for #8386 and a few related things. That should hurt perf very slightly. I'd like to get these perf improvements in so as to stay "in the black". (and to keep the cleanup separate from the non-trivial upcoming diffs) |
Superceded by #18218. |
other + relativedelta(...)
withother + timedelta(...)
orother.replace(...)
where possible. Clearer and more performant.