title: What is the best integer n-tuple hash in python?
body: <p>Adopting from the <a href="http://www.docjar.com/html/api/java/util/Arrays.java.html" rel="nofollow">Java Array class</a> (lines 2938-2947) we can do:</p>
  
  <pre><code>def java_like_hash(tup):
      return reduce(lambda x,y: 31*x+y, (1,)+tup)
  </code></pre>
  
  <p>But is this optimal for python?</p>