Skip to content

GCI1442 [Team TREE][2025] - Reduce memory footprint of dataclasses #82

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

fabienhusseperso
Copy link

@fabienhusseperso fabienhusseperso commented May 21, 2025

Added rule GCI1442.

Since python 3.10 dataclass instances can easily enable a memory optimization
By default, when we define a class in Python, it uses a dict to store its attributes and methods.
This means that every instance of the class has an extensible dictionary to store its data, this flexibility comes at the cost of memory usage.
When we use slots, Python creates a tuple to store the attributes of the class instead of a dictionary, reducing memory usage.

Reference :
green-code-initiative/creedengo-challenge#32
green-code-initiative/creedengo-rules-specifications#409

Copy link

@MP-Aubay MP-Aubay left a comment

Choose a reason for hiding this comment

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

PR seems good (just remove overring of creedengo-rules-specifications)

pom.xml Outdated
@@ -69,7 +69,7 @@
<mockito.version>5.17.0</mockito.version>

<!-- temporary version waiting for a real automatic release in creedengo repository -->
<creedengo-rules-specifications.version>2.2.2</creedengo-rules-specifications.version>
<creedengo-rules-specifications.version>main-SNAPSHOT</creedengo-rules-specifications.version>

Choose a reason for hiding this comment

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

This should not be commited

Copy link
Author

Choose a reason for hiding this comment

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

Yes thank you. Done

Copy link

This PR has been automatically marked as stale because it has no activity for 30 days.
Please add a comment if you want to keep the issue open. Thank you for your contributions!

@github-actions github-actions bot added the stale label Jun 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants