pickle.Pickler

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

## Class Pickler

Known Subclasses:
  `Serializer`

Method Summary
| ``__init__`(self, file, protocol, bin)` This takes a file-like object for writing a pickle data stream.
| ``clear_memo`(self)` Clears the pickler's "memo".
| ``dump`(self, obj)` Write a pickled representation of obj to the open file.
| `get(self, i, pack)`
| ``memoize`(self, obj)` Store an object in the memo.
| `persistent_id(self, obj)`
| `put(self, i, pack)`
| `save(self, obj)`
| `save_bool(self, obj)`
| `save_dict(self, obj)`
| `save_empty_tuple(self, obj)`
| `save_float(self, obj, pack)`
| `save_global(self, obj, name, pack)`
| `save_inst(self, obj)`
| `save_int(self, obj, pack)`
| `save_list(self, obj)`
| `save_long(self, obj, pack)`
| `save_none(self, obj)`
| `save_pers(self, pid)`
| `save_reduce(self, func, args, state, listitems, dictitems, obj)`
| `save_string(self, obj, pack)`
| `save_tuple(self, obj)`
| `save_unicode(self, obj, pack)`
| `_batch_appends(self, items)`
| `_batch_setitems(self, items)`

Class Variable Summary
`dict` | `dispatch` = `{<type 'NoneType'>: <function save_none at 0x...`
`int` | `_BATCHSIZE` = 1000

Method Details

### __init__(self, file, protocol=None, bin=None) (Constructor) 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) 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.

### dump(self, obj) Write a pickled representation of obj to the open file.

### memoize(self, obj) Store an object in the memo.

Class Variable Details

    ### dispatch Type: `dict` Value:
        {<type 'classobj'>: <function save_global at 0x4049c5dc>,
         <type 'instance'>: <function save_inst at 0x4049c5a4>,
         <type 'float'>: <function save_float at 0x4049c3ac>,
         <type 'int'>: <function save_int at 0x4049c33c>,
         <type 'list'>: <function save_list at 0x4049c4c4>,
         <type 'long'>: <function save_long at 0x4049c374>,
         <type 'dict'>: <function save_dict at 0x4049c534>,
         <type 'NoneType'>: <function save_none at 0x4049c2cc>,
        ...

    ### _BATCHSIZE Type: `int` Value:
        1000

Generated by Epydoc 2.1 on Thu Nov 23 23:40:42 2006 | http://epydoc.sf.net