Newbie Q: Class Privacy (or lack of)
Marc 'BlackJack' Rintsch
bj_666 at gmx.net
Wed Aug 2 12:18:21 EDT 2006
In <slrned1ikh.o5q.apardon at rcpc42.vub.ac.be>, Antoon Pardon wrote:
> On 2006-07-28, Marc 'BlackJack' Rintsch <bj_666 at gmx.net> wrote:
>> This avoids the problem but you get others in return. And it's an
>> abuse of `__slots__` which is meant as a way to save memory if you need
>> really many objects of that type and not as "protection".
>
> I find that a strange purpose because when you are working on a class,
> you don't necessarily know if you will ever know many instance of that
> class. So should I use __slots__ in all my classes, just to be sure for
> when someone wants many instances of one?
No you should not use it unless you are sure there will be really many
instances of that class. Putting __slots__ in the mix without a
compelling reason is premature optimization.
Ciao,
Marc 'BlackJack' Rintsch
More information about the Python-list
mailing list