Please help with MemoryError

Tim Chase python.list at
Fri Feb 12 15:54:27 CET 2010

Aahz wrote:
>>> Not quite.  One critical difference between dbm and dicts
>>> is the need to remember to "save" changes by setting the
>>> key's valud again.
>> Could you give an example of this?  I'm not sure I
>> understand what you're saying.
> Well, you're more likely to hit this by wrapping dbm with shelve (because
> it's a little more obvious when you're using pickle directly), but
> consider this:
>     d =, "c")
>     x = MyClass()
>     d['foo'] = x
> = 123
> Your dbm does NOT have the change to recorded, you must do this
> again:
>     d['foo'] = x
> With a dict, you have Python's reference semantics.

Ah, that makes sense...fallout of the "dbm only does string 
keys/values".  It try to adhere to the "only use strings", so I'm 
more cognizant of when I martial complex data-types in or out of 
those strings.  But I can see where it could bite a person.



More information about the Python-list mailing list