Skip to content

Conversation

@albertca
Copy link

@albertca albertca commented Jul 1, 2025

Add slots makes python not to instantiate a dict for each object which improves memory usage.

This is specially important with applications that create a large number of tags.

The only issue with slots is that one cannot have a class attribute that has the same name as an object attribute. This causes an issue with is_inline and is_pretty.

In the current patch I simply commented the code that allows to change those attributes in a given object instance (it can be declared at class-level only), but it can be solved either by renaming is_inline with simply inline at class-level or object-level.

I can implement either one or the other, I don't care, but of course any of those changes means a backwards compatibility issue. Who do we want to annoy: those declaring new classes or those redefining is_inline and is_pretty on object instantiation?

Apart from the slots, which I could verify that really reduce the memory footprint, I did some minor changes cosmetic changes which I can revert.

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.

1 participant