title: Why does Python slow to a crawl in this code?
body: <p>So I'm doing an Euler Project problem trying to incorporate the Sieve of Eratosthenes to find the largest prime factor of a number, however when I try to fill my initial hashtable it slows to a crawl and eats up gigs worth of RAM and takes over my CPU. Can anyone explain why? I realize the code itself is probably subpar </p>
  
  <pre class="lang-py prettyprint-override"><code>allNums = {}
  maxNum=600851475143
  maxFactor=0
  
  #fill dictionary, slows to a crawl here
  for x in xrange(2,maxNum+1):
      allNums[x]=True
  
  #sieve of Erastosthenes 
  for x in xrange(2,len(allNums)):
      y=x
      if allNums[x]:
          y **= 2
          while y&lt;=maxNum:
              if allNums[y]:
                  allNums.pop(y)
              y+=x
  
  #largest prime factor
  for x in allNums:
      if maxNum%x==0 and x&gt;maxFactor:
          maxFactor=x
  
  print x
  </code></pre>