[BangPypers] Object Oriented Programming in python
saager.mhatre at gmail.com
Mon Oct 21 07:56:22 CEST 2013
On Oct 21, 2013 11:14 AM, "Noufal Ibrahim" <noufal at nibrahim.net.in> wrote:
> Saager Mhatre <saager.mhatre at gmail.com> writes:
> > since even slots are accessible from outside an object
> __slots__ are not meant for data hiding. They're meant as a final "trick"
to save memory when you have a large number of objects of the class you're
> If you define a __slots__ variable, you lose the class dictionary (since
that consumes some amount of memory) but you get smaller objects. The gory
details are here
Ah, that explains so much. I've always been confused about slots and the
documentation almost always added to it. Does this mean that once you drop
to slots, you also lose the descriptor- based dispatch magic? That would
make this a pretty desperate hack for some last resort memory conservation!
More information about the BangPypers