When I define a new-style class in Python, I can get the defined attributes (names and values) by using the __dict__
-Attribute, that contains a dictionary of the things.
I'd like to use slots in my classes and their subclasses, because I will created hundreds of thousands of instances and want to save some memory. However, classes that do use __slots__
will not have a __dict__
-Attribute so I can not reflectively access their values that way.
Is there another way, preferable one that preserves the order of the attributes defined for such a class?
Any help would be greatly appreciated!