24 May
2008
24 May
'08
8:19 p.m.
Steven Bethard wrote:
Note however that use of __slots__ is still controversial. (Because it's really only appropriate if you plan to make many of these objects and you want to keep memory consumption down.)
Also, if you were going to go down the route of creating classes on the fly, you would want a factory function to create a class suitable for the purpose at hand, and then make instances of that class. Otherwise, you would be creating a new class for every *instance* of your struct, which would be extremely wasteful (type objects are *big*!) And if you're doing that, you might as well just have some built-in or library class that you can subclass. -- Greg