title: Time complexity of accessing a Python dict
body: <p>I am writing a simple Python program.  </p>
  
  <p>My program seems to suffer from linear access to dictionaries, 
  its run-time grows exponentially even though the algorithm is quadratic.<br>
  I use a dictionary to memoize values. That seems to be a bottleneck.  </p>
  
  <p>The values I'm hashing are tuples of points.
  Each point is: (x,y), 0 &lt;= x,y &lt;= 50<br>
  Each key in the dictionary is: A tuple of 2-5 points: ((x1,y1),(x2,y2),(x3,y3),(x4,y4))</p>
  
  <p>The keys are read many times more often than they are written.</p>
  
  <p>Am I correct that python dicts suffer from linear access times with such inputs?  </p>
  
  <p>As far as I know, sets have guaranteed logarithmic access times.<br>
  How can I simulate dicts using sets(or something similar) in Python?  </p>
  
  <p><em>edit</em> As per request, here's a (simplified) version of the memoization function:</p>
  
  <pre><code>def memoize(fun):
      memoized = {}
      def memo(*args):
          key = args
          if not key in memoized:
              memoized[key] = fun(*args)
          return memoized[key]
      return memo
  </code></pre>