What is the story with __slots__ support in Micropython #13745
Replies: 1 comment 1 reply
-
@brianreinhold There was a very old PR to prototype this, now abandoned, I haven't seen anybody looking into this recently. It is potentially a good optimisation if you intend to create many instances of the same type. Essentially a given attribute on an instance takes up two words (for its key and value), and also you waste empty positions in the dictionary, whereas with Performance wise slots isn't a big gain, in fact it could be slower because you miss out on map caching. I'm not quite sure what mean by the second part, maybe you could give two code examples to compare. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
My understanding is that there has been some consideration to support the
__slots__
feature in Micropython but I don't know if that has happened, is in the works, or has been abandoned. Anyone know?As a bonus, my understanding is that it is more efficient to use self variables in a class than passing parameters to instance methods BUT in defining self variables, does that take more memory?
Beta Was this translation helpful? Give feedback.
All reactions