[Python-Dev] A new dictionary implementation (original) (raw)

Alex alex.gaynor at gmail.com
Wed Feb 1 19:19:28 CET 2012


Guido van Rossum <guido python.org> writes:

Hey, I like this! It's a subtle encouragement for developers to initialize all their instance variables in their init or new method, with a (modest) performance improvement for a carrot. (Though I have to admit I have no idea how you do it. Wouldn't the set of dict keys be different while init is in the middle of setting the instance variables?)

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

While I absolutely cannot speak to this implementation. Traditionally this type of approach is refered to as maps, and was pioneered in SELF, originally presented at OOPSLA '89: http://dl.acm.org/citation.cfm?id=74884 . PyPy also uses these maps to back it's object, although from what I've read the implementation looks nothing like the proposed one for CPython, you can read about that here: http://bit.ly/zwlOkV , and if you're really excited about this you can read our implementation here: https://bitbucket.org/pypy/pypy/src/default/pypy/objspace/std/mapdict.py .

Alex



More information about the Python-Dev mailing list