title: What is the default __hash__ in python?
body: <p>I am quite often using funky stuff as keys for dictionaries, and therefore, I am wondering what is the right way to do it - and this goes through implementing good hash methods for my objects. I am aware of other questions asked here like <a href="https://stackoverflow.com/questions/2909106/python-whats-a-correct-and-good-way-to-implement-hash">good way to implement <strong>hash</strong></a>, but I'd like to understand how the default <code>__hash__</code> works for custom objects, and if it is possible to rely on it.  </p>
  
  <p>I have noticed that mutables are explicitely unhashable since <code>hash({})</code> raises an error ... but strangely, custom classes are hashable :</p>
  
  <pre><code>&gt;&gt;&gt; class Object(object): pass
  &gt;&gt;&gt; o = Object()
  &gt;&gt;&gt; hash(o)
  </code></pre>
  
  <p>So, does anybody knows how this default hash function works ? By understanding this, I'd like to know :</p>
  
  <p>Can I rely on this default hash, if I put objects of a same type as keys of a dictionary ? e.g. :</p>
  
  <pre><code>key1 = MyObject()
  key2 = MyObject()
  key3 = MyObject()
  {key1: 1, key2: 'blabla', key3: 456}
  </code></pre>
  
  <p>Can I rely on it if I use objects of different types as keys in a dictionary ? e.g.</p>
  
  <pre><code>{int: 123, MyObject(10): 'bla', 'plo': 890}
  </code></pre>
  
  <p>And in the last case also, how to make sure that my custom hashes don't clash with the builtin hashes ? e.g :</p>
  
  <pre><code>{int: 123, MyObject(10): 'bla', MyObjectWithCustomHash(123): 890}
  </code></pre>