Closed oakleybrunt closed 2 months ago
You'll have to give some context here @oakleybrunt - I don't know what __slots__
does/how one would use it. If it's just a performance thing then we probably don't care - the performance bottleneck is by far and away the code parsing performed by fparser.
You'll have to give some context here @oakleybrunt - I don't know what
__slots__
does/how one would use it. If it's just a performance thing then we probably don't care - the performance bottleneck is by far and away the code parsing performed by fparser.
Ah, okay. If the performance bottleneck is the parsing, then this is not worth it.
It seems to me that we could be utilising the
__slots__
attribute on classes to reduce attribute access time and save some memory. For most if not all classes, we are already sure of what attributes each class is going to have which means that using__slots__
to bypass use of a class__dict__
for attribute lookups would work well. For example, in the case of unique LFRic Kern classes, all of them must share the same attributes, so why not put them into__slots__
? They can still be set and changed, they just won't live in a dictionary.