On Fri, Apr 16, 2010 at 4:51 PM, Benjamin Peterson <benja...@python.org>wrote:

> 2010/4/16 Daniel Stutzbach <dan...@stutzbachenterprises.com>:
> > IIRC, there's a performance hack in dictobject.c that keeps track of
> whether
> > all of the keys are strings or not.  The hack is designed so that lookup
> > operations can call the string compare/hash functions directly if
> possible,
> > rather than going through the slower PyObject_ functions.
>
> That won't work. You could put non-string keys in a dictionary and
> remove them, but the dictionary would still be in the less optimized
> state.
>

It would be enough to make the common case fast (1 pointer comparison).  The
error case would need to check all of the keys, true, but that's not really
a performance concern.

Unless you're saying you often create a dictionary, add non-string keys,
remove the non-string keys, then pass it as a **kwds? ;-)
--
Daniel Stutzbach, Ph.D.
President, Stutzbach Enterprises, LLC <http://stutzbachenterprises.com>
_______________________________________________
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