Liam Clarke wrote: > Well, all I can say is, don't use them unless you need them, they're a > lot of hassle.
I think the conventional advice is something like, if you don't understand why using slots is a bad idea, you have no business using them :-) > I created two versions of the same object, same attribute values, one > with slots, one without. > > With slots, it pickled to a string of 163 characters. Without, > 341.That's 178 bytes saved, rough approximation. So, if I create 5000 > objects, I've saved somewhere around 900Kb of RAM. Does the size of the pickle correlate to the size of the runtime object? I don't know... Kent > > At 500,000 objects I'd be saving roughly 86Mb of RAM, assuming that a > pickled object corresponds to one in memory. Or, 86Mb of HD space. > > Of course, having to learn what __getstate__ was in order to pickle > the slotted instance wasn't much fun. Remember, premature optimisation > is bad... > > This was a smaller object, so it'll be interesting to see what economy > an object with 70ish attributes makes. FWIW, I'm doing the exact > opposite of XP, and building to handle 300,000 to 600,000 objects... > > Regards, > > Liam Clarke > _______________________________________________ > Tutor maillist - [email protected] > http://mail.python.org/mailman/listinfo/tutor > > _______________________________________________ Tutor maillist - [email protected] http://mail.python.org/mailman/listinfo/tutor
