why is my hash being weird??
Steve Holden
steve at holdenweb.com
Thu Jan 19 10:20:24 EST 2006
pycraze wrote:
> You are appending to the test file. How many times have
> you appended to it? Once? Twice? A dozen times? Just
> what is in the file test.py after all this time?
>
>
>>when input =4
>
> > ./s 4 >test.py
>
>>test.py is
>> myhash = {}
>> def summa():
>> global myhash
>> myhash[0] = 0
>> myhash[1] = 1
>> myhash[2] = 2
>> myhash[3] = 3
>>
>>if now input is 100 then test py will be
>>
>> myhash = {}
>> def summa():
>> global myhash
>> myhash[0] = 0
>> myhash[1] = 1
>> myhash[2] = 2
>> myhash[3] = 3
>> .......
>> .......
>> .......
>> .......
>> myhash[99] = 99
>
>
>> I append only once , and that too i do this exercise to get a largely big hash.
>
>
>
> This result came to a bit of a suprise.. when i construct large hashes
> .. my system gets stalled....
>
> So i was interested how, for this i came up with this exercise .
OK. Now examine a similar program:
myhash = {}
def summa(n):
global myhash
for i in range(n):
myhash[i] = i
summan(1000000)
and see how this compares with your program having a million lines of
source. Then repeat, changing the argument to summa. Then draw some
conclusions. Then report those results back.
regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006 www.python.org/pycon/
More information about the Python-list
mailing list