-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
standalone implementation of ccalendar #18540
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 #18540 +/- ##
==========================================
- Coverage 91.35% 91.33% -0.03%
==========================================
Files 164 164
Lines 49801 49801
==========================================
- Hits 45494 45484 -10
- Misses 4307 4317 +10
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #18540 +/- ##
==========================================
- Coverage 91.59% 91.57% -0.02%
==========================================
Files 153 153
Lines 51212 51212
==========================================
- Hits 46908 46898 -10
- Misses 4304 4314 +10
Continue to review full report at Codecov.
|
what PR was this originally implemented in? |
pandas/_libs/tslibs/ccalendar.pyx
Outdated
|
||
@cython.wraparound(False) | ||
@cython.boundscheck(False) | ||
cpdef monthrange(int64_t year, Py_ssize_t month): |
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.
why do we need this as a function that returns a tuple. its it simply better to split into 2, e.g. monthday and dayofweek? its 2 functions, but then these become all nogil
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.
Those two separate functions also exist here. There's not much reason to retain monthrange, you're right.
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.
are you changing this in this PR?
|
||
y -= m < 3 | ||
day = (y + y / 4 - y / 100 + y / 400 + sakamoto_arr[m - 1] + d) % 7 | ||
# convert to python day |
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.
add a link to python dayofweek docs (e.g. its sunday 0, -6)
# convert to python day | ||
return (day + 6) % 7 | ||
|
||
|
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.
on get_week_of_year you have boundscheck/wraparound but not here, do we need in either?
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 comment about is_leapyear
? If so, is_leapyear doesn't do any array lookups, so those decorators are irrelevant.
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.
yea
@@ -0,0 +1,14 @@ | |||
# -*- coding: utf-8 -*- | |||
# cython: profile=False |
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 only used in fields? no-where else?
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.
Only implemented in fields. Haven't updated others yet. A couple places in offsets, a few more fastpaths in Timestamp.
#18489, but that was reverted as out-of-scope |
Just pushed a commit that uses master
PR
|
pandas/_libs/tslibs/ccalendar.pyx
Outdated
|
||
@cython.wraparound(False) | ||
@cython.boundscheck(False) | ||
cpdef monthrange(int64_t year, Py_ssize_t month): |
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.
are you changing this in this PR?
|
||
|
||
@cython.wraparound(False) | ||
@cython.boundscheck(False) |
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 changing the boundscheck/wraparound in this PR?
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.
Hadn't planned on it. Are they harmful?
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.
prob not harmful but extra code and confusing. pls change.
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.
Well in get_week_of_year
there are array lookups, so disabling these checks should be perf-relevant, shouldn't they?
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.
where are the array lookups?
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.
Line 174 lookup in month_offset
Hadn't planned on it. Even if it shouldn't be used, ATM it still is used in a few places. Besides I wrote a really nice docstring. |
what changed? we had this discussion about why returning a tuple is a bad idea |
@cython.wraparound(False) | ||
@cython.boundscheck(False) | ||
@cython.cdivision | ||
cdef int dayofweek(int y, int m, int d) nogil: |
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.
It seems you are duplicating things from np_datetime.c
?
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.
It seems you are duplicating things from np_datetime.c ?
@jorisvandenbossche think porting less than duplicating. The np_datetime.c version is never actually used in src/datetime (will remove old version in follow-up). As long as perf doesn't take a hit, the default should by python/cython right?
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.
Sorry I don't understand your explanation. Previously it was imported it from np_datetime.c, and you reimplemented it here and changed that import. That seems like duplication rather than porting?
dayofweek
is maybe not used in np_datetime.c itself, but is_leapyear
is, so that one cannot just be removed there.
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.
That seems like duplication rather than porting?
You're right. The intention is to remove the np_datetime.c version in a follow-up PR.
is_leapyear
will be duplicated because it is used in np_datetime.c, as you noted. The idea is that np_datetime.c* is a heavy dependency (in practice tends to come with tslibs.np_datetime
and np_datetime_strings.c) which can be replaced with a much lighter (and more pythonic) ccalendar
dependency in some cases.
* The name overlap between np_datetime.c and tslibs.np_datetime is not my favorite.
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 rather include extra deps than duplicate code. mark this for a followup.
Will remove. |
|
||
|
||
@cython.wraparound(False) | ||
@cython.boundscheck(False) |
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.
where are the array lookups?
rebase and will look again |
@cython.wraparound(False) | ||
@cython.boundscheck(False) | ||
@cython.cdivision | ||
cdef int dayofweek(int y, int m, int d) nogil: |
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 rather include extra deps than duplicate code. mark this for a followup.
For the moment only updated cimports in
fields
.git diff upstream/master -u -- "*.py" | flake8 --diff