On 02/02/2012 11:30, Chris Withers wrote:
On 01/02/2012 17:50, Guido van Rossum wrote:
Another question: a common pattern is to use (immutable) class
variables as default values for instance variables, and only set the
instance variables once they need to be different. Does such a class
benefit from your improvement?

A less common pattern, but which still needs to work, is where a mutable class variable is deliberately store state across all instances of a class...

Given that Mark's patch passes the Python test suite I'm sure basic patterns like this *work*, the question is which of them take advantage of the improved memory efficiency. In the case you mention I don't think it's an issue at all, because the class level attribute doesn't (generally) appear in instance dicts.

What's also common is where the class holds a *default* value for instances, which may be overridden by an instance attribute on *some* instances.

All the best,

Michael Foord

Chris



--
http://www.voidspace.org.uk/

May you do good and not evil
May you find forgiveness for yourself and forgive others
May you share freely, never taking more than you give.
-- the sqlite blessing http://www.sqlite.org/different.html

_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to