The Python reference provides some explanation of how __reduce__ works (see http://docs.python.org/lib/node321.html) . I have read this page and yet don't have a clear understanding of the pickle protocol.
It is not clear to me what happens when no __reduce__ is implemented and only __getstate__ and __setstate__ are implemented for extension types. If anyone can explain thru' an example it'll really help.
Thanks!
User Profile
Collapse
-
Dictionary comparison?
I would like to understand the internals of the dictionary comparison in python.
The python reference manual says that:
"If a class does not define a __cmp__() method it should not define a __hash__() operation either". Why does this dependency exist?
I tried to google for it, but couldn't find proper documentation. Any pointers will be helpful.
Thank you! -
Thanks, printing that out did solve the problem! homeDir was getting set to None when running the script for the first time.... -
Trouble creating bsddb database
I am trying to create a bsddb database where I would like to store all the relevant database files created by my application under one directory.
My code looks as follows:
...Code:from bsddb import db from os import mkdir from os.path import exists homeDir = 'pidgindb' db_env = db.DBEnv() db_env.set_cachesize(0, 1024*1024*50) if not exists(homeDir): homeDir -
-
Thanks, your response was useful!
Could you please point me to the article you wrote, I could not find it....Leave a comment:
-
How to pickle dictionaries?
I am trying to make some of the in-memory dictionaries in my code persistent using bsddb 4.3. Here is an example dictionary in my code for which I would like to create a persistent version:
...Code:# Example dictionary patterns = {pat1: {t1:None}, pat2: {t1:None, t2:None}, pat3: {t2:None}} # Each key is an instance of the class T # Each value is a dictionary, where
No activity results to display
Show More
Leave a comment: