-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Start porting offsets to cython #17830
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
CircleCI test errors look unrelated. Are they showing up elsewhere? |
Codecov Report
@@ Coverage Diff @@
## master #17830 +/- ##
==========================================
- Coverage 91.23% 91.21% -0.03%
==========================================
Files 163 163
Lines 50105 49909 -196
==========================================
- Hits 45715 45523 -192
+ Misses 4390 4386 -4
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #17830 +/- ##
==========================================
- Coverage 91.24% 91.22% -0.03%
==========================================
Files 163 163
Lines 50168 50083 -85
==========================================
- Hits 45777 45686 -91
- Misses 4391 4397 +6
Continue to review full report at Codecov.
|
This can be cut down if the diff is too large for easy review. Looking forward to getting the |
@@ -312,7 +312,7 @@ def _get_freq_str(base, mult=1): | |||
# --------------------------------------------------------------------- | |||
# Offset names ("time rules") and related functions | |||
|
|||
|
|||
from pandas._libs.tslibs.offsets import _offset_to_period_map |
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.
can de-privatize later
pandas/tseries/offsets.py
Outdated
@@ -14,6 +14,13 @@ | |||
from pandas._libs import tslib, Timestamp, OutOfBoundsDatetime, Timedelta | |||
from pandas.util._decorators import cache_readonly | |||
|
|||
from pandas._libs.tslib import _delta_to_nanoseconds | |||
from pandas._libs.tslibs.offsets import ( # noqa | |||
ApplyTypeError, CacheableOffset, |
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.
you shouldn't need the noqa, that means you are importing extra things that are not needed. IOW some of these are just used internally (now in offsets.pyx)
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.
The two unused imports are WeekDay
and CacheableOffset
. They're both used in the tests (though CacheableOffset not really). I'll update the imports and get rid of the noqa.
dt.microsecond != 0 or getattr(dt, 'nanosecond', 0) != 0): | ||
return False | ||
return True | ||
|
||
# --------------------------------------------------------------------- | ||
# DateOffset | ||
|
||
|
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.
can you add a note in other api changes, that CacheableOffset & Weekday are no longer public (prob not ever used publicly but who knowns).
cimport numpy as np | ||
np.import_array() | ||
|
||
|
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.
ok with de-privatizing things internally here (can be later as well)
pass | ||
|
||
|
||
# TODO: unused. remove? |
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.
is this used?
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.
No. This came up recently in #17914.
also pls run the perf for timeseries & offsets and report any issues. should slightly speed things up. be careful with the cacheable stuff though. |
Hello @jbrockmendel! Thanks for updating the PR. Cheers ! There are no PEP8 issues in this Pull Request. 🍻 Comment last updated on October 28, 2017 at 06:04 Hours UTC |
About to re-run with CPU affinity to be on the safe side. |
what were these doing to be so before?
|
@jbrockmendel pls always always rebase on master before you run a benchmark. this is against a commit from 10/9. Pretty much anytime you do anything you should rebase. |
Woops, good catch. Re-running now. |
(re-running) The most commonly-called function that got moved to cython is |
Same results again. I'll dig into the |
ok this looks fine. ping after perf review (though that looks like a minor issue). |
Using cProfile I get a tiny speedup with the new version. With %timeit I get results similar to asv but a narrower difference. This is a mystery I'm OK with, given that follow-ons are going to optimize the tar out of these. |
thanks @jbrockmendel
I wouldn't have expected much as these are mostly used in scalar type things which are 1-offs; and these are not typed much either (so that may help) |
@jbrockmendel Is there a reason that CacheableOffset and WeekDay are no longer public in |
WeekDay is just an enum map and CacheableOffest is not usable on its own |
OK (note they are not private in the sense they are non-underscored classes in a module that is publicly exposed, but indeed seems like deprecation is not really needed in this case) |
This is mostly cut/paste, avoiding moving any of the classes for the time being. There is a small change in
_to_dt64
that will be described in a comment below.Defined
dtstrings
for flake8 cleanup in setup.