It's ok to __slots__ for what they were intended
John Nagle
nagle at animats.com
Fri Dec 21 12:04:10 EST 2007
Chris Mellon wrote:
> On 20 Dec 2007 19:50:31 -0800, Aahz <aahz at pythoncraft.com> wrote:
>> In article <0829587b-f3a1-4f77-86a1-163e7bcc54d2 at l32g2000hse.googlegroups.com>,
>> Carl Banks <pavlovevidence at gmail.com> wrote:
>>>> Someday I'll have time to write up a proper page about why you shouldn't
>>>> use __slots__....
> Barking out your blanket warning in a thread on *the exact use case
> slots were implemented to address* just makes you look like a mindless
> reactionary. Stick to posting your warning in threads where people ask
> how to stop "other people" from setting attributes on "their"
> instances.
Agreed.
I'd like to hear more about what kind of performance gain can be
obtained from "__slots__". I'm looking into ways of speeding up
HTML parsing via BeautifulSoup. If a significant speedup can be
obtained when navigating large trees of small objects, that's worth
quite a bit to me.
John Nagle
SiteTruth
More information about the Python-list
mailing list