[Tutor] cPickle/pickle help

Alan Gauld alan.gauld at btinternet.com
Wed Apr 4 19:57:01 CEST 2012

On 04/04/12 18:25, b. nyec wrote:

> I'm not sure if this is the correct list to post this on,

No its not, this list is for folks learning Python the language.

> but i was wondering i someone could help me.

You might get lucky here but are more likely to find responses
on the main Python mailing list/newsgroup:


 > I'm wondering if there exists a pickler example written in C ?

The pickle module is intended to be used in Python rather than from C.
The examples are therefore written from a Python users standpoint.
However it is possible to embed Python into your C program and there are 
separate documents to describe how to do that. That might be the easiest 
way to approach this, but I' ve never tried so don't know.

> I understand the cPickle module was written in C, but looking

Many Python modules are written in C but they are all intended to be 
used from within Python. Reading the code could show you how to 
read/write the various data types, but you would need to replicate the C 
functions in the module in your code.

> I found a post on this list here: http://mail.python.org/pipermail//tutor/2011-September/085414.html
 > that shows an example of pickling data to disk.

It doesn't matter much since the Python code is the same, it just runs 
faster with cPickle. The only difference is whether you start with

import pickle
import cPickle

I recommend you try the main list.
And the embedding Python option is worth investigating:


Alan G
Author of the Learn to Program web site

More information about the Tutor mailing list