__slots_ and inheritance

Alexander Schmolck a.schmolck at gmx.net
Thu Apr 10 09:24:11 EDT 2003


Alex Martelli <aleaxit at yahoo.com> writes:

> I suspect that any confusion may be caused by seeing __slots__
> as something OTHER than an optimization -- for example, as a
> way to reproduce the behavior of other languages where you
> can, or must, specify possible attributes for every class.  It
> isn't, really -- it's a memory-consumption optimization.

This confusion seems sort of understandable, given "What's new to python2.2"
introduced it explicitly as a bug avoidance feature.

__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




More information about the Python-list mailing list