title: Fastest way to generate a random-like unique string with random length in Python 3
body: <p>I know how to create random string, like:</p>
  
  <pre><code>''.join(secrets.choice(string.ascii_uppercase + string.digits) for _ in range(N))
  </code></pre>
  
  <p>However, there should be no duplicates so what I am currently just checking if the key already exists in a list, like shown in the following code:</p>
  
  <pre><code>import secrets
  import string
  import numpy as np
  
  
  amount_of_keys = 40000
  
  keys = []
  
  for i in range(0,amount_of_keys):
      N = np.random.randint(12,20)
      n_key = ''.join(secrets.choice(string.ascii_uppercase + string.digits) for _ in range(N))
      if not n_key in keys:
          keys.append(n_key)
  </code></pre>
  
  <p>Which is okay for a small amount of keys like <code>40000</code>, however the problem does not scale well the more keys there are. So I am wondering if there is a faster way to get to the result for even more keys, like <code>999999</code></p>