-
-
Notifications
You must be signed in to change notification settings - Fork 18.2k
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
PERF: Implement get_freq_code in cython frequencies #17422
Conversation
Codecov Report
@@ Coverage Diff @@
## master #17422 +/- ##
==========================================
- Coverage 91.15% 91.13% -0.03%
==========================================
Files 163 163
Lines 49581 49552 -29
==========================================
- Hits 45198 45161 -37
- Misses 4383 4391 +8
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #17422 +/- ##
==========================================
- Coverage 91.15% 91.14% -0.02%
==========================================
Files 163 163
Lines 49581 49561 -20
==========================================
- Hits 45198 45171 -27
- Misses 4383 4390 +7
Continue to review full report at Codecov.
|
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.
if u are claiming. perf boost then pls add asv
pandas/_libs/tslibs/frequencies.pyx
Outdated
from util cimport is_integer_object | ||
|
||
|
||
@cython.ccall |
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.
what does this decorator do?
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.
@cython.ccall
def foo(x):
is equivalent to cpdef foo(x):
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.
then use cpdef foo(x)
; don't try to change the existing style in a single PR.
asv is throwing build-time errors. I've filed an issue there. For now the timeit results will have to do. |
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 still want actual asv code
@jorisvandenbossche Any chance you want to play "good cop" here? I could use some help with asv, see error discussion here. |
@jbrockmendel you need to add asv benchmarks to he code you are pushing you are touching highly perf sensistive code and it is very easy to break things |
Just pushed a commit that adds asv checks for Period property lookups. I can't get asv to run it, would appreciate it if someone else would give it a shot. |
pandas/_libs/tslibs/frequencies.pyx
Outdated
from util cimport is_integer_object | ||
|
||
|
||
@cython.ccall |
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.
then use cpdef foo(x)
; don't try to change the existing style in a single PR.
Note that this code was moved from non-cython, so is not changing existing style. The idea was that where possible, retaining pure-python compatibility would be nice. But not a big deal, so will change. |
Looks like Travis error is an unrelated HTTP timeout. |
pandas/_libs/tslibs/frequencies.pyx
Outdated
|
||
import numpy as np | ||
cimport numpy as np | ||
np.import_array() # Without this, `is_integer_object` causes segfaults |
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.
remove the comment, this is standard to do.
ok this looks good. just remove that comment and push again to get everything passing. ping on green. |
ping. |
https://travis-ci.org/pandas-dev/pandas/jobs/272723119 is failing. FYI just because they are in the allowed failing section doesn't mean they actually should fail. this is the build test, which installs like a user, w/o a development build. |
@@ -492,6 +493,8 @@ def pxd(name): | |||
'sources': ['pandas/_libs/src/datetime/np_datetime.c', | |||
'pandas/_libs/src/datetime/np_datetime_strings.c', | |||
'pandas/_libs/src/period_helper.c']}, | |||
'_libs.tslibs.frequencies': {'pyxfile': '_libs/tslibs/frequencies', |
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.
this also needs to be listed in the setup
function, IOW all sub-dirs have to be listed, put it after pandas._libs
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.
see comments
Looks like the allowed-fail mentioned earlier is now OK, but the 3.5 OSX is now failing, says it just stalled and received no output for 10 minutes. The only change since last night's all-green is the entry in the setup.py packages. |
Implement .pxd file for tslibs.frequencies cimport get_freq_code in period.pyx Replace isinstance checks in period.pyx with C-equivalents form util Remove unused imports from period.pyx Remove code in tseries.frequencies that can now be imported from tslibs.frequencies
There's a whole bunch of
tseries.frequencies
andtseries.offsets
that should be moved into cython to improvePeriod
(andPeriodIndex, and to a lesser extend
Timestamp) performance. This PR just starts with the function
get_freq_code`.To keep the PR small, there are a bunch of things it doesnt do that can further improve things in follow-ups:
_libs.period
still getsget_freq_code
fromtseries.frequencies
instead of directly fromtslibs.frequencies
tseries.frequencies
are not removed.Before:
After:
git diff upstream/master -u -- "*.py" | flake8 --diff