A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2003-May/035608.html below:

[Python-Dev] Re: __slots__ and default values

[Python-Dev] Re: __slots__ and default values [Python-Dev] Re: __slots__ and default valuesRaymond Hettinger python@rcn.com
Wed, 14 May 2003 02:51:24 -0400
> It's also a bad idea for initializers that aren't immutable, because
> the initial values are shared between all instances (another example
> of the "aliasing" problem, also known from default argument values).

Right.  I once knew that and had forgotten.


> > Though I think of __slots__ as a way to make lighter weight instances,
> > constraining instance variables is also one of its functions. 
> 
> Not true.  That is at best an unintended side effect of slots.  And
> there's nothing against having __slots__ include __dict__, so your
> instance has a __dict__ as well as slots.

That's something I never knew but wish I had known (and I *have*
read the source).  Live and learn.


Raymond









RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4