Re: Don't use __slots__! (was Re: dicts vs classes)
In article <[EMAIL PROTECTED]>, Roy Smith <[EMAIL PROTECTED]> wrote: >>Guido sez: >> >> __slots__ is a terrible hack with nasty, hard-to-fathom side >> effects that should only be used by programmers at grandmaster and >> wizard levels. Unfortunately it has gained an enormous undeserved >> popularity amongst the novices and apprentices, who should know >> better than to use this magic incantation casually. > >But, if they are novices, why should they be expected to know better? > >I just re-read http://docs.python.org/ref/slots.html#l2h-217 and don't >see anyplace where it says, "Warning: for use by wizards only". Unfortunately, the Python docs are currently suboptimal when it comes to new-style classes. -- Aahz ([EMAIL PROTECTED]) <*> http://www.pythoncraft.com/ "Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." --Brian W. Kernighan -- http://mail.python.org/mailman/listinfo/python-list
Re: Don't use __slots__! (was Re: dicts vs classes)
>Guido sez: > > __slots__ is a terrible hack with nasty, hard-to-fathom side > effects that should only be used by programmers at grandmaster and > wizard levels. Unfortunately it has gained an enormous undeserved > popularity amongst the novices and apprentices, who should know > better than to use this magic incantation casually. But, if they are novices, why should they be expected to know better? I just re-read http://docs.python.org/ref/slots.html#l2h-217 and don't see anyplace where it says, "Warning: for use by wizards only". -- http://mail.python.org/mailman/listinfo/python-list
Re: Don't use __slots__! (was Re: dicts vs classes)
In article <[EMAIL PROTECTED]>, <[EMAIL PROTECTED]> wrote: >Aahz, citing Guido: >> >>__slots__ is a terrible hack with nasty, hard-to-fathom side >>effects that should only be used by programmers at grandmaster and >>wizard levels. Unfortunately it has gained an enormous undeserved > >I think I have used __slots__ just one time. Can you tell me some of of >such bad side effects? The main one is that inheritance becomes difficult to nearly-impossible. -- Aahz ([EMAIL PROTECTED]) <*> http://www.pythoncraft.com/ "Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." --Brian W. Kernighan -- http://mail.python.org/mailman/listinfo/python-list
Re: Don't use __slots__! (was Re: dicts vs classes)
Aahz, citing Guido: >__slots__ is a terrible hack with nasty, hard-to-fathom side >effects that should only be used by programmers at grandmaster and >wizard levels. Unfortunately it has gained an enormous undeserved I think I have used __slots__ just one time. Can you tell me some of of such bad side effects? Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list
Don't use __slots__! (was Re: dicts vs classes)
In article <[EMAIL PROTECTED]>, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: >In <[EMAIL PROTECTED]>, Guyon Morée >wrote: >> >> I'm using simple classes as a container of named values and I'm >> instantiating a lot of them in a very short time. >> >> i was wondering if there is any benefit in using dicts instead from a >> performance/memory usage point of view? > >If you really have a memory problem read the documentation about >`__slots__`. But I would only consider this if `a lot of` is several 100k >or millions of objects and the memory consumption really is a problem. Guido sez: __slots__ is a terrible hack with nasty, hard-to-fathom side effects that should only be used by programmers at grandmaster and wizard levels. Unfortunately it has gained an enormous undeserved popularity amongst the novices and apprentices, who should know better than to use this magic incantation casually. -- Aahz ([EMAIL PROTECTED]) <*> http://www.pythoncraft.com/ "Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." --Brian W. Kernighan -- http://mail.python.org/mailman/listinfo/python-list