Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Is there a difference between cPickle / pickle for dump?

Reply
Thread Tools

Is there a difference between cPickle / pickle for dump?

 
 
Guenter Walser
Guest
Posts: n/a
 
      10-15-2003
Hello,

When using the codeline:

pickle.dump(self, file, pickle.HIGHEST_PROTOCOL)

my program runs perfectly fine:

--------------------------- Testprotocol
-----------------------------
Initialise an non existing index - creation of persistence files is
tested. ... ok

----------------------------------------------------------------------
Ran 1 test in 0.000s
OK
------------------------- Eo Testprotocol
----------------------------

when using instead:

cPickle.dump(self, file, cPickle.HIGHEST_PROTOCOL)

then it behaves not so well:
--------------------------- Testprotocol
-----------------------------
Initialise an non existing index - creation of persistence files is
tested. ... ERROR

================================================== ====================
ERROR: Initialise an non existing index - creation of persistence
files is tested.

----------------------------------------------------------------------
Traceback (most recent call last):
File "testIndex.py", line 95, in testInitIndexSuccess
print ind
File "C:\PROGRA~1\Python2.3\lib\site-packages\Kombuka\KBIndex.py",
line 91, in storeIndex
cPickle.dump(self, file, cPickle.HIGHEST_PROTOCOL)
PicklingError: Can't pickle <class 'Kombuka.KBIndex.KBIndex'>:
import of module Kombuka.KBIndex failed

----------------------------------------------------------------------
Ran 1 test in 0.451s
FAILED (errors=1)
------------------------- Eo Testprotocol
----------------------------

Python will start to write into the file, but stops after the first
character.
I can't find any hint in the doc that there is a difference for the dump
method between the two modules.

Self is a dictionary (inherited from dict) with only one entry
(string:string), the environment is Windows XP.

Thanks in advance

Guenter


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
cPickle vs pickle discrepancy Zac Burns Python 0 01-06-2009 01:04 AM
cPickle.dumps differs from Pickle.dumps; looks like a bug. Victor Kryukov Python 8 05-17-2007 05:29 AM
pickle, cPickle, & HIGHEST_PROTOCOL A.B., Khalid Python 1 01-30-2005 10:57 PM
Does shelve use cPickle or Pickle? Adrian B. Python 1 02-07-2004 10:04 AM
problem using pickle / cPickle Jesse Bloom Python 1 01-03-2004 05:25 AM



Advertisments