Re: Initializing the number of slots in a dictionary

2006-08-07 Thread Fuzzyman
Jon Smirl wrote: > On Sun, 06 Aug 2006 15:33:30 -0700, John Machin wrote: [snip..] > > > > Do you have an application with a performance problem? If so, what makes > > you think inserting 1M items into a Python dict is contributing to the > > problem? > > I know in advance how many items will be a

Re: Initializing the number of slots in a dictionary

2006-08-07 Thread Jon Smirl
On Mon, 07 Aug 2006 00:33:33 -0400, Tim Peters wrote: > ... > > [Jon Smirl] >> I know in advance how many items will be added to the dictionary. Most >> dictionary implementations I have previously worked with are more >> efficient if they know ahead of time how big to make their tables. > > Ric

Re: Initializing the number of slots in a dictionary

2006-08-06 Thread Tim Peters
... [Jon Smirl] > I know in advance how many items will be added to the dictionary. Most > dictionary implementations I have previously worked with are more > efficient if they know ahead of time how big to make their tables. Richard Jones spent considerable time investigating whether "pre-sizing

Re: Initializing the number of slots in a dictionary

2006-08-06 Thread Jon Smirl
On Sun, 06 Aug 2006 15:33:30 -0700, John Machin wrote: > Jon Smirl wrote: >> Is there some way to tell a dictionary object that I am going to load 1M >> objects into it and have it pre-allocate enought slots to hold all of >> the entries? > > Not according to the manual. > > Not according to the

Re: Initializing the number of slots in a dictionary

2006-08-06 Thread John Machin
Jon Smirl wrote: > Is there some way to tell a dictionary object that I am going to load 1M > objects into it and have it pre-allocate enought slots to hold all of the > entries? Not according to the manual. Not according to the source [as at 2.4.3]. In any case, if there were a back-door undocum

Initializing the number of slots in a dictionary

2006-08-06 Thread Jon Smirl
Is there some way to tell a dictionary object that I am going to load 1M objects into it and have it pre-allocate enought slots to hold all of the entries? Thus avoiding many thousand memory allocations. Jon Smirl [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list