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

196 lluissalord patch 1 #243

Merged
merged 4 commits into from
Oct 26, 2023
Merged

196 lluissalord patch 1 #243

merged 4 commits into from
Oct 26, 2023

Conversation

c0fec0de
Copy link
Owner

No description provided.

lluissalord and others added 4 commits May 10, 2022 13:23
The usage of `__slots__` is highly recommended in order to reduce memory usage on classes, even more for the ones which are used a lot of time as it could be `NodeMixin`. The benefit here is that `__dict__` is not generated then and a lot of memory is saved with this. Besides, with this change any class which inherit `NodeMixin` can now benefit of not creating `__dict__` and reduce the memory usage, otherwise child classes cannot reduce memory with this trick if the parent class does not implement it too.

However, the rest of the classes of this package which inherit from `NodeMixin` should not use `__slots__` because they benefit from the flexibility of `__dict__`. Hence, this benefit is only for implementations which use directly `NodeMixin`, as mine.

In order to set some statistics, in my implementation, the use of this change help us reduce the memory usage of the custom node classes by 49,91% and by 71,85%. Hence, as these classes are highly used on my implementation this can represent a lot of MBs reduction on memory usage.
@c0fec0de c0fec0de merged commit c45cb46 into main Oct 26, 2023
14 checks passed
@c0fec0de c0fec0de deleted the 196-lluissalord-patch-1 branch November 6, 2023 06:46
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

2 participants