Definition of 'pickle' 
Author Message
 Definition of 'pickle'

Dear people,

I don't understand the definition provided in the python documentation
for 'pickle':

The pickle module implements a fundamental, but powerful algorithm for
serializing and de-serializing a Python object structure. ``Pickling''
is the process whereby a Python object hierarchy is converted into a
byte stream, and ``unpickling'' is the inverse operation, whereby a
byte stream is converted back into an object hierarchy. Pickling (and
unpickling) is alternatively known as ``serialization'',
``marshalling,''3.2 or ``flattening'', however the preferred term used
here is ``pickling'' and ``unpickling'' to avoid confusing.

thanks!

zeallous



Sun, 13 Nov 2005 19:59:10 GMT  
 Definition of 'pickle'
Quote:

> Dear people,

> I don't understand the definition provided in the Python documentation
> for 'pickle':

[snip]

I have had no need of it and I am quite newbie myself on Python, but
AFAIK pickle can be used for example saving (and loading) object
instances to a file, or for example sending instances over the net to
another location (and another application).

Quite like serialization in Java, I think.

--
Rami Saarinen

Please do remove the obvious part from my email address if you wish to
reply personally.



Sun, 13 Nov 2005 20:42:01 GMT  
 Definition of 'pickle'


Quote:
> The pickle module implements a fundamental, but powerful algorithm
for
> serializing and de-serializing a Python object structure.

``Pickling''

As far as I know "to pickle" means saving not only the data to a file
but also it's data type! Have you ever seen that garbage in a .DAT
file? Most of them are serialized files.

Lorenzo



Sun, 13 Nov 2005 20:56:37 GMT  
 Definition of 'pickle'
Basically, pickling allows you to take a complex data type such as a
dictionary, array, list, or tuple (for example), and store that information
in a byte stream which can then be written to a file.  When you "unpickle"
that stream, you have the complex data type, not just a text representation
of it.

ColdFusion (my day job, sorry :p ) has a similar function which uses WDDX ('an
XML-based technology that enables the exchange of complex data betwen web
programming languages' - www.openwddx.org) to store the data in.  With WDDX,
you can create an associative array in ColdFusion, convert it (serialize),
save it to a file, then take any other language that supports WDDX (let's
say, PHP), open that file up, deserialize it, and have an associative array
in that language.  Unfortunately I'm not familiar enough with pickle to say
whether its the same format as WDDX or not.

Simple example:

Quote:
>>> import pickle
>>> x = []
>>> x.append('a')
>>> x.append('b')
>>> x
['a', 'b']
>>> type(x)
<type 'list'>
>>> pickle.dump(x, file('pick.p', 'w')) # creates a file, pick.p
>>> z = pickle.load(file('pick.p', 'r'))
>>> z
['a', 'b']
>>> type(z)

<type 'list'>

hth

jay


Quote:
> Dear people,

> I don't understand the definition provided in the Python documentation
> for 'pickle':

> The pickle module implements a fundamental, but powerful algorithm for
> serializing and de-serializing a Python object structure. ``Pickling''
> is the process whereby a Python object hierarchy is converted into a
> byte stream, and ``unpickling'' is the inverse operation, whereby a
> byte stream is converted back into an object hierarchy. Pickling (and
> unpickling) is alternatively known as ``serialization'',
> ``marshalling,''3.2 or ``flattening'', however the preferred term used
> here is ``pickling'' and ``unpickling'' to avoid confusing.

> thanks!

> zeallous

--
Jay Dorsey
python at jay dorsey dot com


Sun, 13 Nov 2005 20:19:39 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Securing 'pickle'

2. two definitions of 'cyclic'?

3. Technical: Definition of ``alyasing''

4. Definition of 'apply' of MDI GUI

5. A definition for 'foreach'

6. 'manpage'-like CL-Definitions availiable ?

7. 'multiple definitions' with MacOS X

8. Why can't instance methods be pickled?

9. Pickle doen't work on PythonCE

10. Pickle and finding a class's module

11. Pickling within ASP files doesn't work

12. Technical: Definitions of ``Poynter'', ``Shyfting''

 

 
Powered by phpBB® Forum Software