title: Python: how to check if an item was added to a set, without 2x (hash, lookup)
body: <p>I was wondering if there was a clear/concise way to add something to a set and check if it was added without 2x hashes &amp; lookups.</p>
  
  <p>this is what you might do, but it has 2x hash's of item</p>
  
  <pre><code>if item not in some_set:  # &lt;-- hash &amp; lookup
      some_set.add(item)    # &lt;-- hash &amp; lookup, to check the item already is in the set
  
      other_task()
  </code></pre>
  
  <p>This works with a single hash and lookup but is a bit ugly.</p>
  
  <pre><code>some_set_len = len(some_set)
  some_set.add(item)
  if some_set_len != len(some_set):
  
      other_task()
  </code></pre>
  
  <p>Is there a better way to do this using Python's set api?</p>