how to detect if a dictionary has been modified ?

Stef Mientki stef.mientki at gmail.com
Sun Nov 23 19:04:38 EST 2008


>>
>> Good point.  What about
>>
>>  
>>>>> d = {1: []}
>>>>> d[1].append(2)
>>>>>         
>>
>> Has d changed or not?
>>   
>
> Which just goes to show that the SDict implementation above is, as 
> suspected by the author, incomplete for the purpose of detecting all 
> changes to the dict, as well as detecting some that might not be 
> perceived as changes.
>
I now see there's no simple solution.
And above my normal copy also doesn't work in the above case.
So for the moment I'll use a deepcopy,
hopes that work.
In the future I'll see if it's possible that the "changer" will set the 
modify flag.

thank you all for the contributions.

Paul and "bearophile", you talks about "functional" languages and 
balanced trees are a bit too high for my knowledge,
all though the program in which I need this is a functional language 
environment and based on dataflow programming ;-)

cheers,
stef



More information about the Python-list mailing list