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/2007-June/073626.html below:

[Python-Dev] Question about dictobject.c:lookdict_string

[Python-Dev] Question about dictobject.c:lookdict_stringCarl Friedrich Bolz cfbolz at gmx.de
Mon Jun 11 17:23:10 CEST 2007
Eyal Lotem wrote:
> My question is specifically regarding the transition back from
> lookdict_string (the initial value) to the general lookdict.
> 
> Currently, when a string-only dict is trying to look up any
> non-string, it reverts back to a general lookdict.
> 
> Wouldn't it be better (especially in the more important case of a
> string-key-only dict), to revert to the generic lookdict when a
> non-string is inserted to the dict, rather than when one is being
> searched?
[...]
> This does not seem like a significant issue, but as I know a lot of
> effort went into optimizing dicts, I was wondering if I am missing
> something here.

Yes, you are: when doing a lookup with a non-string-key, that key could 
be an instance of a class that has __hash__ and __eq__ implementations 
that make the key compare equal to some string that is in the 
dictionary. So you need to change to lookdict, otherwise that lookup 
might fail.

Cheers,

Carl Friedrich Bolz
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