Davy <[EMAIL PROTECTED]> writes: > In Python 2.5 document, defaultdict is called high performance > container. From document, we can know defaultdict is subclass of dict. > So, why defaultdict have higher performance than dict?
I don't think the "high performance" attribute is supposed to mean that it has higher performanec than dict, only that it is not a simple-minded hack on top of dict, but code carefully written in C with performance in mind -- like dict itself. > That is, when use defaultdict and when use dict? Any suggestions are > welcome! Use defaultdict when you need the dict to handle missing keys automatically, dict in all other cases. If in doubt, simply use dict. -- http://mail.python.org/mailman/listinfo/python-list