[Python-Dev] dict and required hashing
Benjamin Peterson
benjamin at python.org
Sat Apr 19 02:39:49 CEST 2014
On Fri, Apr 18, 2014, at 17:30, Steven D'Aprano wrote:
> On Fri, Apr 18, 2014 at 02:57:55PM -0700, Benjamin Peterson wrote:
> > On Fri, Apr 18, 2014, at 14:46, Jim J. Jewett wrote:
> > > (1) I believe the recent consensus was that the number of comparisons
> > > made in a dict lookup is an implementation detail. (Please correct me
> > > if I am wrong.)
> >
> > Absolutely.
> >
> > >
> > > (2) Is "the item will be hashed at least once" a language guarantee?
> >
> > No. (Would that be useful at all?)
>
> I'm curious under what circumstances a key won't be hashed at all.
It's probably always hashed now, but as Jim suggested, it might happen
in an optimization. For example, if you try to do a lookup on an empty
dict, you definitely don't need to hash anything.
More information about the Python-Dev
mailing list