title: Python Comparing 2 list and 2 tuple with equality sign
body: <p>Recently I have been learning more about hashing in Python and I came around this <a href="https://www.journaldev.com/17357/python-hash-function" rel="nofollow noreferrer">blog</a> where it states that:</p>
  
  <blockquote>
    <p>Suppose a Python program has 2 lists. If we need to think about
    comparing those two lists, what will you do? Compare each element?
    Well, that sounds fool-proof but slow as well!</p>
    
    <p>Python has a much smarter way to do this. When a tuple is constructed
    in a program, Python Interpreter calculates its hash in its memory. If
    a comparison occurs between 2 tuples, it simply compares the hash
    values and it knows if they are equal!</p>
  </blockquote>
  
  <p>So I am really confused about these statements.</p>
  
  <p>First when we do:
  <code>[1, 2, 3] == [1, 2, 3]</code> then how does this equality works ? Does it calculate the hash value and then compare it ?</p>
  
  <p>Second what's the difference when we do:</p>
  
  <p><code>[1, 2, 3] == [1, 2, 3]</code> and <code>(1, 2, 3) == (1, 2, 3)</code> ?</p>
  
  <p>Because when I tried to find time of execution with timeit then I got this result:</p>
  
  <pre><code>$ python3.5 -m timeit '[1, 2, 3] == [1, 2, 3]'
  10000000 loops, best of 3: 0.14 usec per loop
  $ python3.5 -m timeit '(1, 2, 3) == (1, 2, 3)'
  10000000 loops, best of 3: 0.0301 usec per loop
  </code></pre>
  
  <p>So why there is difference in time from <code>0.14</code> for list to <code>0.03</code> for tuple which is faster than list.</p>