-
Notifications
You must be signed in to change notification settings - Fork 9
Improve memory usage of entries #68
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
Conversation
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.
Pull request overview
This PR aims to improve memory usage of array entries by adding __slots__ to the ResArray class. The __slots__ mechanism prevents Python from creating a __dict__ for each instance, which can significantly reduce memory overhead when many instances are created.
Key Changes:
- Added
__slots__definition toResArrayclass containing all instance attributes:start,stream,_keyword,_length,_type,_data_start, and_is_eof
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
25f7fdd to
e6920dc
Compare
e6920dc to
2efea40
Compare
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.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -25,10 +25,6 @@ class FormattedArray(ResArray): | |||
| An array entry in an formatted res file. | |||
| """ | |||
Copilot
AI
Dec 12, 2025
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.
The FormattedArray subclass should define __slots__ = () to prevent the creation of __dict__ in instances. When a base class uses __slots__, subclasses that don't explicitly define their own __slots__ will still have a __dict__ attribute, which defeats the memory optimization purpose of using __slots__ in the base class. Add an empty __slots__ = () declaration to this class.
| """ | |
| """ | |
| __slots__ = () |
andreas-el
left a comment
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.
💯
This is by using slots for arrays. This seems to give a very minor improvement to performance.