The built-in hash function differs from Python2.5 to Python2.7.

If you are planning to migrate from Python 2.5 to Python 2.7 and
you were dumb enough to store the value of python 2.5's hash
function, just like I did, you might be interested in the following
code snippet.

This is the hash function that Google uses in production for python 2.5:

def c_mul(a, b):

  return eval(hex((long(a) * b) & 0xFFFFFFFFFFFFFFFFL)[:-1])

def py25hash(self):

  if not self:

    return 0 # empty

  value = ord(self[0]) << 7

  for char in self:

    value = c_mul(1000003, value) ^ ord(char)

  value = value ^ len(self)

  if value == -1:

    value = -2

  return value


I wonder why Google is not using 64bit hashes in Python 2.7

Cheers,
-Andrin

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appengine@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.

Reply via email to