Is 100,000 entries big for a dictionary?

Greg Landrum glandrum at my-deja.com
Sat Dec 30 00:03:50 CET 2000


In article <92iug4$vqb$1 at nnrp1.deja.com>,
  rturpin at my-deja.com wrote:
> I'm in the process of architecting an application with medium sized
data
> sets. Python dictionaries are tempting as part of the representation
> mechanism. How do they perform when they have 100,000 entries? Can you
> offer any other experience with this size data set in Python?
>

One of the nice things about python is that it's easy to test things
like this.  The following simple test:
#--------------
import time

def populate(n):
  d = {}
  for i in xrange(n):
    d[i] = i
  return d

def access(n,d):
  for i in xrange(n):
    foo = d[i]


n = 1e5

print 'populating'
t1 = time.clock()
d = populate(n)
t2 = time.clock()
print '\tthat took %f seconds'%(t2-t1)

print 'accessing'
t1 = time.clock()
access(n,d)
t2 = time.clock()
print '\tthat took %f seconds'%(t2-t1)
#------------
runs in about less than a second on my crappy desktop machine.
(350MHz PIII running Win2K)

-greg


Sent via Deja.com
http://www.deja.com/



More information about the Python-list mailing list