Skip to content
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

Merged
merged 2 commits into from
Sep 17, 2017

Conversation

jbrockmendel
Copy link
Member

Trying to break the fixes to offsets into small pieces. Recall the goal is to make DateOffset immutable so as to fix the very slow __eq__ calls that get made by Period.__eq__ and the PeriodIndex 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.

This is a step towards making dateOffset immutable, is an approach suggested by @shoyer
@@ -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):
Copy link
Contributor

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)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@codecov
Copy link

codecov bot commented Sep 7, 2017

Codecov Report

Merging #17450 into master will decrease coverage by 0.02%.
The diff coverage is 84.21%.

Impacted file tree graph

@@            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
Flag Coverage Δ
#multiple 88.92% <84.21%> (-0.01%) ⬇️
#single 40.25% <36.84%> (-0.06%) ⬇️
Impacted Files Coverage Δ
pandas/tseries/offsets.py 96.97% <84.21%> (-0.18%) ⬇️
pandas/io/gbq.py 25% <0%> (-58.34%) ⬇️
pandas/core/frame.py 97.72% <0%> (-0.1%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d457791...d2d4e66. Read the comment docs.

@codecov
Copy link

codecov bot commented Sep 7, 2017

Codecov Report

Merging #17450 into master will decrease coverage by 0.02%.
The diff coverage is 85.71%.

Impacted file tree graph

@@            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
Flag Coverage Δ
#multiple 88.92% <85.71%> (-0.01%) ⬇️
#single 40.25% <33.33%> (-0.07%) ⬇️
Impacted Files Coverage Δ
pandas/tseries/offsets.py 96.97% <85.71%> (-0.18%) ⬇️
pandas/io/gbq.py 25% <0%> (-58.34%) ⬇️
pandas/core/frame.py 97.72% <0%> (-0.1%) ⬇️
pandas/core/indexes/range.py 92.28% <0%> (+0.09%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d457791...d2d4e66. Read the comment docs.

@gfyoung gfyoung added Clean Internals Related to non-user accessible pandas implementation labels Sep 9, 2017
@jreback jreback added Frequency DateOffsets Performance Memory or execution speed performance labels Sep 17, 2017
@jreback jreback added this to the 0.21.0 milestone Sep 17, 2017
@jreback jreback merged commit 553a829 into pandas-dev:master Sep 17, 2017
@jreback
Copy link
Contributor

jreback commented Sep 17, 2017

this is fine. thanks.

@jbrockmendel jbrockmendel deleted the offset_cache branch October 30, 2017 16:23
alanbato pushed a commit to alanbato/pandas that referenced this pull request Nov 10, 2017
No-Stream pushed a commit to No-Stream/pandas that referenced this pull request Nov 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Clean Frequency DateOffsets Internals Related to non-user accessible pandas implementation Performance Memory or execution speed performance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants