speeding up dictionary creation

Bob van der Poel bvdpoel at uniserve.com
Thu Aug 17 16:49:30 EDT 2000


I've certainly NOT done an extensive test on this, but...I'm using
python to edit a mini-database. Each record is a dictionary entry:

	items['foo']=...
	items['spam']=...

it appears to me that when reading/parsing the initial datafile the
majority of the time is taken in creating new entries, not in parsing
the file. Is there a way to preallocate entries or otherwise speed this
up. On a short set to data there doesn't seem to be a problem, but as
the list increases in size the load time goes up in what appears to be
N^2.

I assume this stems from the time needed to check for existing
recordnames not conflicting with existing ones...

-- 
   __
  /  )      /         Bob van der Poel
 /--<  ____/__        bvdpoel at uniserve.com
/___/_(_) /_)         http://users.uniserve.com/~bvdpoel




More information about the Python-list mailing list