Re: Adding tuples to a dictionary

2007-06-11 Thread Maciej Blizi ski
Thank you for all the answers! My problem is solved even better than I expected! @Peter: Yes, the garbage collector was causing the slowdown. Switching it off sped the program up; each iteration was taking the same amount of time. I ran collection manually every 10 iterations to control memory usa

Re: Adding tuples to a dictionary

2007-06-01 Thread Nick Craig-Wood
[EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Let me comment on what happens in you're code: > The place where you create new objects is > keys = [str(x) for x in range(20)] # here you create 20 > strings which will be reused ( by reference ) >and > my_dict[key] = (key, key) # h

Re: Adding tuples to a dictionary

2007-05-31 Thread bvukov
On May 31, 8:30 pm, Maciej Bliziński <[EMAIL PROTECTED]> wrote: > Hi Pythonistas! > > I've got a question about storing tuples in a dictionary. First, a > small test case which creates a list of dictionaries: > > import time > > list_of_dicts = [] > keys = [str(x) for x in range(20)] > prev_clk

Re: Adding tuples to a dictionary

2007-05-31 Thread Peter Otten
Maciej Blizi?ski wrote: > Hi Pythonistas! > > I've got a question about storing tuples in a dictionary. First, a > small test case which creates a list of dictionaries: > > import time > > list_of_dicts = [] > keys = [str(x) for x in range(20)] > prev_clk = time.clock() > for i in range(20)

Adding tuples to a dictionary

2007-05-31 Thread Maciej Bliziński
Hi Pythonistas! I've got a question about storing tuples in a dictionary. First, a small test case which creates a list of dictionaries: import time list_of_dicts = [] keys = [str(x) for x in range(20)] prev_clk = time.clock() for i in range(20): my_dict = {} for key in keys: