-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Remove unnecessary iNaT checks from _Period properties #17421
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
Codecov Report
@@ Coverage Diff @@
## master #17421 +/- ##
==========================================
- Coverage 91.15% 91.14% -0.02%
==========================================
Files 163 163
Lines 49581 49581
==========================================
- Hits 45198 45189 -9
- Misses 4383 4392 +9
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #17421 +/- ##
==========================================
- Coverage 91.22% 91.2% -0.02%
==========================================
Files 163 163
Lines 49586 49586
==========================================
- Hits 45233 45225 -8
- Misses 4353 4361 +8
Continue to review full report at Codecov.
|
can we remove |
AFAICT the only remaining usages are in tests. It is exposed so technically could be used by someone somewhere. I'm trying to err on the side of doing-too-little in PRs to keep the reviewer(s) happy. |
can you add asv's for these Period properites (and then run the comparions). |
See additions to the asv period file.
For once I actually believe the results! |
this looks like it overlaps with #17422 somewhat. ok with merging either first; but I suspect you will want to rework this one to directly call the cython routine (get_freq_codes) . lmk. |
My preference would be to merge them separately-- they should not conflict-- and then in a follow-up to #17422 I'll make a pass through all of |
ok that's fine, let's fixup / merge #17422 first |
The Travis error is a greyed-out circle. Not sure what to make of it. Does this require action on my part? |
travis was hicupping. why don't you rebase and push again. |
thanks! |
In the status quo,
pd.Period.year
goes through several layers of redirection, one of which checks forself.ordinal == iNaT
.But
Period.ordinal
will never beiNaT
, becausePeriod.__new__
returnsNaT
in that case instead of aPeriod
object. So we can skip thevalue == iNaT
check inget_period_field
. With that out of the way, we can skip_get_accessor_func
and_field
and and just write inpyear(ordinal, freq)
.This PR changes this property lookup for
year
,month
,day
, ...Speedups ~10% across the board. Before:
After:
git diff upstream/master -u -- "*.py" | flake8 --diff