-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Port Timedelta implementation to tslibs.timedeltas #17937
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
Move _op_unary_method and _binary_op_method_timedeltalike out of Timedelta namespace
is this mostly cut/paste? |
Yes. Some methods in The only actual changes are in There are some non-trivial upcoming changes, but I'm trying to make your life easier by not mixing those in with cut/paste edits. |
Codecov Report
@@ Coverage Diff @@
## master #17937 +/- ##
==========================================
- Coverage 91.25% 91.23% -0.02%
==========================================
Files 163 163
Lines 50120 50120
==========================================
- Hits 45737 45728 -9
- Misses 4383 4392 +9
Continue to review full report at Codecov.
|
i think need to fix the NaT things first rather than halfway so this |
Are you saying you want the edits in core.indexes in a separate PR? This is basically unrelated to #17793. |
yes on both |
OK, just reverted the changes in core.indexes, will put them in a separate PR. |
Updated with one more method ( |
you might be able to move TImedelta completely to the new module as you now can import NaT directly w/o tslib and if you change the Timestamp checks to isinstance(obj, datetime). |
actually you already stated this, hahah |
Yep. I'd prefer to close this out and do the rest in a separate PR, but either way is OK. |
I think let's move this all at once |
OK. The all-at-once needs to wait for #18014. The reason I prefer to do this in two steps is because the follow up can be pure cut/paste, whereas this contains nonzero other changes that have already been reviewed. |
(also this re-fixes a bunch of flake8 errors that got un-fixed in one of my rebase screwups) |
give this a rebase. |
Suggestions? This is on-deck to be a blocker |
I'd like to move the entire Timedelta impl out of tslib.pyx |
So would I, but we're either going to have to settle for almost all of it or for having an ugly circular-esque import with |
The methods moved in this PR are cut/paste, whereas the other methods that need to be moved will take some tinkering, for a less trivial review process. There is value in separating these steps. |
ok, then pls add to your list moving the rest of Timedelta. It can be entirely defined in timedeltas. I think its ok to import it inside a function if needed, you can probably do isinstance checks on timedelta/datetime as needed as well (rather than Timedelta). you can also maybe just duck-type check for Timestamp e.g.
|
Great. I had assumed that wouldn't be acceptable performance-wise, but never bothered to measure it. That makes the remaining porting a lot simpler; pushing shortly. |
Cut/paste Timedelta and _Timedelta methods into tslibs.timesdeltas._Timedelta. The moved methods are copied verbatim.
Timedelta._binary_op_method_timedeltalike and Timedelta._op_unary_method do not use
self
, are moved out of the class definitions (but stay in tslib). (In a follow-up _op_unary_method can be moved to tslibs.timedeltas, _binary_op_method_timedeltalike cannot.)Most of the rest of _Timedelta&Timedelta can be moved into tslibs.timedeltas._Timedelta after #17793.
On the side, cleanup in core.indexes of redundant isinstance checks.
git diff upstream/master -u -- "*.py" | flake8 --diff