[CentralOH] __slots__

Eric Floehr eric at intellovations.com
Sat Oct 9 14:57:39 CEST 2010


My understanding of slots is by doing that you would accomplish two main

1. Decrease instance storage space (because no __dict__), which could make a
big difference if you are creating LOTS of instances.
2. Because there is no __dict__ you lose all the dynamic attribute
capabilities of Python (which is certainly an acceptable tradeoff for
improved memory management).

So yes, it makes sense, as long as you understand what you are trading off
and what you are gaining.


On Sat, Oct 9, 2010 at 8:45 AM, Mark Erbaugh <mark at microenh.com> wrote:

> If a class has no data members, does it make sense to include a __slots__ =
> () statement in the class declaration?
> Thanks,
> Mark
> _______________________________________________
> CentralOH mailing list
> CentralOH at python.org
> http://mail.python.org/mailman/listinfo/centraloh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/mailman/private/centraloh/attachments/20101009/f3ce0e24/attachment.html>

More information about the CentralOH mailing list