Terry Reedy schrieb: >> The first time a non str object is inserted or looked up, the dict >> swiches to a more general lookup methods. > > This makes adding a string-only dict pretty trivial, if desired.
It's not as trivial as it seems. The switch over to the general lookup method happens when a non str object is *looked up*. d = {'a': None} # uses lookdict_string() d.get(1, None) # d now uses lookdict() "d->ma_lookup == lookdict_string" is a sufficient condition, not a condicio sine qua non. > Assuming that 3.x dicts are optimized for the 3.x string type, this is > not a problem for 3.x ;-). Well, it's always optimized for the str type - which happens to be PyUnicodeObject in 3.x. Christian _______________________________________________ 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