[Python-ideas] dict.hash - optimized per module
tjreedy at udel.edu
Mon Oct 18 00:10:13 CEST 2010
On 10/17/2010 3:27 AM, Jan Koprowski wrote:
> My name is Jan and this is my first post on this group. So hello :)
> I'm very sorry if my idea is so naive as to be ridiculous but I
> believe it is worth to ask.
Worth asking but not worth doing (or, in a sense, already done for
function local namespaces).
As Antoine said, strings have their hash computed just once. Recomputing
a namespace-depending hash for each lookup would take far longer than
the occational collision.
For function local names, names are assigned a index at compile time so
that runtime lookup is a super-quick index operation. If you want, call
it perfect hashing with hashes computed once at compile time ;-).
Terry Jan Reedy
More information about the Python-ideas