Is there a difference between cPickle / pickle for dump?

Discussion in 'Python' started by Guenter Walser, Oct 15, 2003.

  1. 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
    Guenter Walser, Oct 15, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jesse Bloom

    problem using pickle / cPickle

    Jesse Bloom, Jan 2, 2004, in forum: Python
    Replies:
    1
    Views:
    387
    Vojin Jovanovic
    Jan 3, 2004
  2. Adrian B.

    Does shelve use cPickle or Pickle?

    Adrian B., Feb 7, 2004, in forum: Python
    Replies:
    1
    Views:
    727
    Gerrit
    Feb 7, 2004
  3. A.B., Khalid

    pickle, cPickle, & HIGHEST_PROTOCOL

    A.B., Khalid, Jan 30, 2005, in forum: Python
    Replies:
    1
    Views:
    379
    Tim Peters
    Jan 30, 2005
  4. Victor Kryukov
    Replies:
    8
    Views:
    484
    Gabriel Genellina
    May 17, 2007
  5. Zac Burns

    cPickle vs pickle discrepancy

    Zac Burns, Jan 6, 2009, in forum: Python
    Replies:
    0
    Views:
    292
    Zac Burns
    Jan 6, 2009
Loading...

Share This Page