A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2009-February/085898.html below:

[Python-Dev] The interpreter accepts f(**{'5':'foo'}); is this intentional?

[Python-Dev] The interpreter accepts f(**{'5':'foo'}); is this intentional? [Python-Dev] The interpreter accepts f(**{'5':'foo'}); is this intentional?Christian Heimes lists at cheimes.de
Thu Feb 5 22:55:24 CET 2009
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
More information about the Python-Dev mailing list

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