473,404 Members | 2,114 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

Is there a difference between cPickle / pickle for dump?

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
Jul 18 '05 #1
0 2025

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Drochom | last post by:
Hello, I have a huge problem with loading very simple structure into memory it is a list of tuples, it has 6MB and consists of 100000 elements >import cPickle >plik = open("mealy","r")...
0
by: Richard Kessler | last post by:
I am attempting a GUI using BOA Constructor. I have some simple code to pickle an object, but for some reason when I use cPickle it hangs the system, but pickle works just fine. I do not have a...
2
by: sh | last post by:
Hi guys, Well, I have a (maybe dumb) question. I want to write my own little blog using Python (as a fairly small but doable project for myself to learn more deaply Python in a web context). ...
1
by: A.B., Khalid | last post by:
I wonder if someone can explain what is wrong here. I am pickling a list of dictionaries (see code attached) and unpickling it back using the HIGHEST_PROTOCOL of pickle and cPickle. I am getting an...
3
by: Rune Strand | last post by:
I'm experiencing strange errors both with pickle and cPickle in the below code: import cPickle as pickle #import pickle from string import ascii_uppercase from string import ascii_lowercase...
4
by: Mingus Tsai | last post by:
Hello- please help with unpickling problem: I am using Python version 2.3.4 with IDLE version 1.0.3 on a Windows XPhome system. My problem is with using cPickle to deserialize my pickled...
8
by: Jeff Poole | last post by:
This is going to be a pretty vague message because it involves a large block of code I'd rather avoid posting. Basically, I've been pickling a dictionary of instances of a class I've created...
1
by: Conrado PLG | last post by:
Say you have this structure: pna/ __init__.py model.py __init__.py is empty. model.py is:
0
by: =?ISO-8859-1?Q?Gerhard_H=E4ring?= | last post by:
gopal mishra wrote: No, there isn't. You could, of course, save each object in its own pickle file. Or use an object database like ZODB instead. -- Gerhard
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.