[Tutor] cPickle/pickle help

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[Tutor] cPickle/pickle help

b. nyec
Hello,

I'm not sure if this is the correct list to post this on, but i was wondering i someone could help me. I'm wondering if there exists a pickler example written in C ? I understand the cPickle module was written in C, but looking at it seems daunting to create sample code from it. 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. I'm wondering if that's pickle or cPickle (protocol version?) ?? What i'm trying to do is write a client in C that will send pickled data to a server written in python for unpicking over TCP. I'm still learning this stuff (pickle/serialization) as i go (i have zero knowledge of python), so apologies if i'm not making any sense as i've had trouble finding help on other places when explaining what i'm trying to accomplish. If this is off topic, feel free to e-mail me privately and i could explain in more detail without adding noise to
 this list.

Thanks for any help.

_______________________________________________
Tutor maillist  -  [hidden email]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
Reply | Threaded
Open this post in threaded view
|

Re: [Tutor] cPickle/pickle help

Alan Gauld
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:

comp.lang.python

 > 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
or
import cPickle

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

http://docs.python.org/extending/embedding.html

HTH,
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/

_______________________________________________
Tutor maillist  -  [hidden email]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
Reply | Threaded
Open this post in threaded view
|

Re: [Tutor] cPickle/pickle help

Mark Lawrence
In reply to this post by b. nyec
On 04/04/2012 18:25, b. nyec wrote:

> Hello,
>
> I'm not sure if this is the correct list to post this on, but i was wondering i someone could help me. I'm wondering if there exists a pickler example written in C ? I understand the cPickle module was written in C, but looking at it seems daunting to create sample code from it. 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. I'm wondering if that's pickle or cPickle (protocol version?) ?? What i'm trying to do is write a client in C that will send pickled data to a server written in python for unpicking over TCP. I'm still learning this stuff (pickle/serialization) as i go (i have zero knowledge of python), so apologies if i'm not making any sense as i've had trouble finding help on other
>   places when explaining what i'm trying to accomplish. If this is off topic, feel free to e-mail me privately and i could explain in more detail without adding noise to
>   this list.
>
> Thanks for any help.
>
> _______________________________________________
> Tutor maillist  -  [hidden email]
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>

You're probably better off asking on comp.lang.python but the advice
will almost certainly be don't do it see e.g.
http://www.velocityreviews.com/forums/t944852-re-re-advise-of-programming-one-of-my-first-programs.html

--
Cheers.

Mark Lawrence.

_______________________________________________
Tutor maillist  -  [hidden email]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
Reply | Threaded
Open this post in threaded view
|

Re: [Tutor] cPickle/pickle help

b. nyec


--- On Wed, 4/4/12, Mark Lawrence <[hidden email]> wrote:

> From: Mark Lawrence <[hidden email]>
> Subject: Re: [Tutor] cPickle/pickle help
> To: [hidden email]
> Date: Wednesday, April 4, 2012, 1:16 PM
> On 04/04/2012 18:25, b. nyec wrote:
> > Hello,
> >
> > I'm not sure if this is the correct list to post this
> on, but i was wondering i someone could help me. I'm
> wondering if there exists a pickler example written in C ? I
> understand the cPickle module was written in C, but looking
> at it seems daunting to create sample code from it. 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. I'm
> wondering if that's pickle or cPickle (protocol version?) ??
> What i'm trying to do is write a client in C that will send
> pickled data to a server written in python for unpicking
> over TCP. I'm still learning this stuff
> (pickle/serialization) as i go (i have zero knowledge of
> python), so apologies if i'm not making any sense as i've
> had trouble finding help on other
> >   places when explaining what i'm trying
> to accomplish. If this is off topic, feel free to e-mail me
> privately and i could explain in more detail without adding
> noise to
> >   this list.
> >
> > Thanks for any help.
> >
> > _______________________________________________
> > Tutor maillist  -  [hidden email]
> > To unsubscribe or change subscription options:
> > http://mail.python.org/mailman/listinfo/tutor
> >
>
> You're probably better off asking on comp.lang.python but
> the advice
> will almost certainly be don't do it see e.g.
> http://www.velocityreviews.com/forums/t944852-re-re-advise-of-programming-one-of-my-first-programs.html
>
> --
> Cheers.
>
> Mark Lawrence.
>
> _______________________________________________
> Tutor maillist  -  [hidden email]
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>

Yep I'm fully aware of the ol "Validate user input" security 101 with pickle. :) Looking around the last few days for help, is point more and more to a project i didn;t quite intend on taking up. Oh well.
Thanks.


_______________________________________________
Tutor maillist  -  [hidden email]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor