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

More __slots__ #374

Merged
merged 2 commits into from Jan 10, 2022
Merged

More __slots__ #374

merged 2 commits into from Jan 10, 2022

Conversation

InnovativeInventor
Copy link
Member

This is a PR broken out from #372 to ease the code review process.

In particular, this patch adds the __slots__ method to a few classes that are created often, which improves memory and runtime performance (marginally but measurably). In theory, this is a breaking change, as users will no longer be able to add arbitrary attributes to the Assignment and SubgraphView class. However, I don't think this is something that people do (it would be quite strange, no?).

This PR inspired by @pjrule #363. See that PR for more details on the reasoning.

@InnovativeInventor InnovativeInventor changed the title More slots More __slots__ Jan 6, 2022
@codecov-commenter
Copy link

codecov-commenter commented Jan 10, 2022

Codecov Report

Merging #374 (ab7acfa) into main (832ad0c) will increase coverage by 0.31%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #374      +/-   ##
==========================================
+ Coverage   87.89%   88.20%   +0.31%     
==========================================
  Files          37       37              
  Lines        1660     1662       +2     
==========================================
+ Hits         1459     1466       +7     
+ Misses        201      196       -5     
Impacted Files Coverage Δ
gerrychain/partition/assignment.py 96.00% <100.00%> (+0.05%) ⬆️
gerrychain/partition/subgraphs.py 100.00% <100.00%> (ø)
gerrychain/tree.py 76.61% <0.00%> (-0.41%) ⬇️
gerrychain/graph/graph.py 92.03% <0.00%> (+5.30%) ⬆️

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 832ad0c...ab7acfa. Read the comment docs.

@pizzimathy pizzimathy self-requested a review January 10, 2022 20:13
@InnovativeInventor
Copy link
Member Author

InnovativeInventor commented Jan 10, 2022

@apizzimenti I just rebased this off main so the diff is correct.

Copy link
Member

@pizzimathy pizzimathy left a comment

Choose a reason for hiding this comment

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

These changes match the design patterns from #363 and improve performance. Seems like a good addition to the codebase.

@InnovativeInventor InnovativeInventor merged commit b686e25 into main Jan 10, 2022
@InnovativeInventor InnovativeInventor deleted the more-slots branch May 24, 2022 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants