[Tutor] hash value input

spir denis.spir at free.fr
Sat Jan 30 10:56:46 CET 2010


On Fri, 29 Jan 2010 08:23:37 -0800
Emile van Sebille <emile at fenx.com> wrote:

> > So, how does python do this?
> >  
> 
> Start here...
> 
> http://effbot.org/zone/python-hash.htm

Great, thank you!
From the above pointed page:

=======
For ordinary integers, the hash value is simply the integer itself (unless it’s -1).

class int:
    def __hash__(self):
        value = self
        if value == -1:
            value == -2
        return value
=======

I'm surprised of this, for this should create as many indexes (in the underlying array actually holding the values) as there are integer keys. With possibly huge holes in the array. Actually, there will certainly be a predefined number of indexes N, and the integers be further "modulo-ed" N. Or what?
I would love to know how to sensibly chose the number of indexes. Pointers welcome (my searches did not bring any clues on the topic).

> Emile

Denis
________________________________

la vita e estrany

http://spir.wikidot.com/


More information about the Tutor mailing list