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
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