title: Python performance comparison for creating sets - set() vs. {} literal
body: <p>A discussion following <a href="https://stackoverflow.com/questions/53918325/differences-for-creating-set-using-set-or/">this question</a> left me wondering, so I decided to run a few tests and compare the creation time of <code>set((x,y,z))</code> vs. <code>{x,y,z}</code> for creating sets in Python (I'm using Python 3.7).</p>
  
  <p>I compared the two methods using <code>time</code> and <code>timeit</code>. 
  Both were consistent* with the following results:</p>
  
  <pre><code>test1 = """
  my_set1 = set((1, 2, 3))
  """
  print(timeit(test1))
  </code></pre>
  
  <p><em>Result: 0.30240735499999993</em></p>
  
  <pre><code>test2 = """
  my_set2 = {1,2,3}
  """
  print(timeit(test2))
  </code></pre>
  
  <p><em>Result: 0.10771795900000003</em></p>
  
  <p>So the second method was <strong>almost 3 times faster</strong> than the first. 
  This was quite a surprising difference to me.
  What is happening under the hood to optimize the performance of the set literal over the <code>set()</code> method in such a way? Which would be advisable for which cases?</p>
  
  <p><strong><em>* Note:</strong> I only show the results of the <code>timeit</code> tests since they are averaged over many samples, and thus perhaps more reliable, but the results when testing with <code>time</code> showed similar differences in both cases.</em></p>
  
  <hr>
  
  <p><strong>Edit:</strong> I'm aware of <a href="https://stackoverflow.com/questions/30216000/why-is-faster-than-list">this similar question</a> and though it answers certain aspects of my original question, it didn't cover all of it. Sets were not addressed in the question, and as <strong>empty sets</strong> do not have a literal syntax in python, I was curious how (if at all) set creation using a literal would differ from using the <code>set()</code> method. Also, I wondered how the handling of the <em>tuple parameter</em> in <code>set((x,y,z)</code> happens behind the scenes and what is its possible impact on runtime.
  The great answer by coldspeed helped clear things up.</p>