pickle :: Pickler :: Class Pickler
[hide private]
[frames] | no frames]

Class Pickler

source code

Instance Methods [hide private]
 
__init__(self, file, protocol=None)
This takes a file-like object for writing a pickle data stream.
source code
 
_batch_appends(self, items) source code
 
_batch_setitems(self, items) source code
 
clear_memo(self)
Clears the pickler's "memo".
source code
 
dump(self, obj)
Write a pickled representation of obj to the open file.
source code
 
get(self, i, pack=<built-in function pack>) source code
 
memoize(self, obj)
Store an object in the memo.
source code
 
persistent_id(self, obj) source code
 
put(self, i, pack=<built-in function pack>) source code
 
save(self, obj) source code
 
save_bool(self, obj) source code
 
save_dict(self, obj) source code
 
save_empty_tuple(self, obj) source code
 
save_float(self, obj, pack=<built-in function pack>) source code
 
save_global(self, obj, name=None, pack=<built-in function pack>) source code
 
save_inst(self, obj) source code
 
save_int(self, obj, pack=<built-in function pack>) source code
 
save_list(self, obj) source code
 
save_long(self, obj, pack=<built-in function pack>) source code
 
save_none(self, obj) source code
 
save_pers(self, pid) source code
 
save_reduce(self, func, args, state=None, listitems=None, dictitems=None, obj=None) source code
 
save_string(self, obj, pack=<built-in function pack>) source code
 
save_tuple(self, obj) source code
 
save_unicode(self, obj, pack=<built-in function pack>) source code
Class Variables [hide private]
  _BATCHSIZE = 1000
  dispatch = {<type 'bool'>: <function save_bool at 0x7fee55c6da...
Method Details [hide private]

__init__(self, file, protocol=None)
(Constructor)

source code 

This takes a file-like object for writing a pickle data stream.

The optional protocol argument tells the pickler to use the given protocol; supported protocols are 0, 1, 2. The default protocol is 0, to be backwards compatible. (Protocol 0 is the only protocol that can be written to a file opened in text mode and read back successfully. When using a protocol higher than 0, make sure the file is opened in binary mode, both when pickling and unpickling.)

Protocol 1 is more efficient than protocol 0; protocol 2 is more efficient than protocol 1.

Specifying a negative protocol version selects the highest protocol version supported. The higher the protocol used, the more recent the version of Python needed to read the pickle produced.

The file parameter must have a write() method that accepts a single string argument. It can thus be an open file object, a StringIO object, or any other custom object that meets this interface.

clear_memo(self)

source code 

Clears the pickler's "memo".

The memo is the data structure that remembers which objects the pickler has already seen, so that shared or recursive objects are pickled by reference and not by value. This method is useful when re-using picklers.


Class Variable Details [hide private]

dispatch

Value:
{<type 'bool'>: <function save_bool at 0x7fee55c6da28>,
 <type 'instance'>: <function save_inst at 0x7fee55c7d050>,
 <type 'classobj'>: <function save_global at 0x7fee55c7d0c8>,
 <type 'float'>: <function save_float at 0x7fee55c6db90>,
 <type 'function'>: <function save_global at 0x7fee55c7d0c8>,
 <type 'int'>: <function save_int at 0x7fee55c6daa0>,
 <type 'list'>: <function save_list at 0x7fee55c6dde8>,
 <type 'long'>: <function save_long at 0x7fee55c6db18>,
...