-
-
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
Use cache_readonly attrs to minimize attrs set in __init__ #17450
Conversation
This is a step towards making dateOffset immutable, is an approach suggested by @shoyer
pandas/tseries/offsets.py
Outdated
@@ -2324,12 +2320,28 @@ def __init__(self, n=1, normalize=False, **kwds): | |||
raise ValueError('{variation} is not a valid variation' | |||
.format(variation=self.variation)) | |||
|
|||
@cache_readonly | |||
def _rd_forward(self): |
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 spell things out. (_relativedelta_forward)
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.
Done.
Codecov Report
@@ Coverage Diff @@
## master #17450 +/- ##
==========================================
- Coverage 91.15% 91.13% -0.03%
==========================================
Files 163 163
Lines 49587 49593 +6
==========================================
- Hits 45203 45197 -6
- Misses 4384 4396 +12
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #17450 +/- ##
==========================================
- Coverage 91.15% 91.13% -0.03%
==========================================
Files 163 163
Lines 49587 49597 +10
==========================================
- Hits 45203 45201 -2
- Misses 4384 4396 +12
Continue to review full report at Codecov.
|
this is fine. thanks. |
Trying to break the fixes to
offsets
into small pieces. Recall the goal is to makeDateOffset
immutable so as to fix the very slow__eq__
calls that get made byPeriod.__eq__
and thePeriodIndex
constructor.As a step towards immutability, this PR is trying to reduce the number of attributes set in
__init__
, as suggested by @shoyer a while back.In two places the
__init__
methods are identical to those of the parent class, so are removed.