__slots_ and inheritance

A. Lloyd Flanagan alloydflanagan at attbi.com
Sat Apr 12 13:52:58 CEST 2003

Alexander Schmolck <a.schmolck at gmx.net> wrote in message news:<yfsistmh4ec.fsf at black132.ex.ac.uk>...
> __slots__ is the one addition in python2.2 that really annoys me. It seems an
> ill-conceived jumble of conceptually unrelated things (bug avoidance,
> optimization, safety, encapsulation) that screws up reflection big time for
> little apparent gain. As Knuth said ...
> 'as

I agree.  The more I looked at it, the more it became clear that
__slots__ turns a class into something very non-pythonic, with
significantly different behavior.  A lot of utilities, debuggers, and
advanced programming tricks will be coming with this disclaimer:
"does not work with any class which defines __slots__"

Unless you absolutely have to have it, don't use it.

More information about the Python-list mailing list