Generating a unique identifier
Hrvoje Niksic
hniksic at xemacs.org
Sat Sep 8 05:38:35 EDT 2007
Steven D'Aprano <steve at REMOVE-THIS-cybersource.com.au> writes:
> Should garbage-collecting 16 million strings really take 20+
> minutes?
It shouldn't. For testing purposes I've created a set of 16 milion
strings like this:
s = set()
for n in xrange(16000000):
s.add('somerandomprefix' + str(n)) # prefix makes the strings a bit larger
It takes maybe about 20 seconds to create the set. Quitting Python
takes 4-5 seconds. This is stock Python 2.5.1.
More information about the Python-list
mailing list