pickle (version 38432)
index
/usr/local/lib/python2.5/pickle.py
Module Docs

Create portable serialized representations of Python objects.
 
See module cPickle for a (much) faster implementation.
See module copy_reg for a mechanism for registering custom picklers.
See module pickletools source for extensive comments.
 
Classes:
 
    Pickler
    Unpickler
 
Functions:
 
    dump(object, file)
    dumps(object) -> string
    load(file) -> object
    loads(string) -> object
 
Misc variables:
 
    __version__
    format_version
    compatible_formats

 
Modules
       
binascii
marshal
re
struct
sys

 
Classes
       
exceptions.Exception(exceptions.BaseException)
PickleError
PicklingError
UnpicklingError
Pickler
Unpickler

 
class PickleError(exceptions.Exception)
    A common base class for the other pickling exceptions.
 
 
Method resolution order:
PickleError
exceptions.Exception
exceptions.BaseException
__builtin__.object

Data descriptors defined here:
__weakref__
list of weak references to the object (if defined)

Methods inherited from exceptions.Exception:
__init__(...)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Data and other attributes inherited from exceptions.Exception:
__new__ = <built-in method __new__ of type object at 0x8125440>
T.__new__(S, ...) -> a new object with type S, a subtype of T

Methods inherited from exceptions.BaseException:
__delattr__(...)
x.__delattr__('name') <==> del x.name
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__getitem__(...)
x.__getitem__(y) <==> x[y]
__getslice__(...)
x.__getslice__(i, j) <==> x[i:j]
 
Use of negative indices is not supported.
__reduce__(...)
__repr__(...)
x.__repr__() <==> repr(x)
__setattr__(...)
x.__setattr__('name', value) <==> x.name = value
__setstate__(...)
__str__(...)
x.__str__() <==> str(x)

Data descriptors inherited from exceptions.BaseException:
__dict__
args
message
exception message

 
class Pickler
     Methods defined here:
__init__(self, file, protocol=None)
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.
get(self, i, pack=<function pack at 0xb716db8c>)
# Return a GET (BINGET, LONG_BINGET) opcode string, with argument i.
memoize(self, obj)
Store an object in the memo.
persistent_id(self, obj)
put(self, i, pack=<function pack at 0xb716db8c>)
# Return a PUT (BINPUT, LONG_BINPUT) opcode string, with argument i.
save(self, obj)
save_bool(self, obj)
save_dict(self, obj)
save_empty_tuple(self, obj)
save_empty_tuple() isn't used by anything in Python 2.3.  However, I
# found a Pickler subclass in Zope3 that calls it, so it's not harmless
# to remove it.
save_float(self, obj, pack=<function pack at 0xb716db8c>)
save_global(self, obj, name=None, pack=<function pack at 0xb716db8c>)
save_inst(self, obj)
save_int(self, obj, pack=<function pack at 0xb716db8c>)
save_list(self, obj)
save_long(self, obj, pack=<function pack at 0xb716db8c>)
save_none(self, obj)
save_pers(self, pid)
save_reduce(self, func, args, state=None, listitems=None, dictitems=None, obj=None)
save_string(self, obj, pack=<function pack at 0xb716db8c>)
save_tuple(self, obj)
save_unicode(self, obj, pack=<function pack at 0xb716db8c>)

Data and other attributes defined here:
dispatch = {<type 'bool'>: <function save_bool at 0xb6e603e4>, <type 'classobj'>: <function save_global at 0xb6e606bc>, <type 'instance'>: <function save_inst at 0xb6e60684>, <type 'float'>: <function save_float at 0xb6e6048c>, <type 'int'>: <function save_int at 0xb6e6041c>, <type 'list'>: <function save_list at 0xb6e605a4>, <type 'long'>: <function save_long at 0xb6e60454>, <type 'dict'>: <function save_dict at 0xb6e60614>, <type 'NoneType'>: <function save_none at 0xb6e603ac>, <type 'str'>: <function save_string at 0xb6e604c4>, ...}

 
class PicklingError(PickleError)
    This exception is raised when an unpicklable object is passed to the
dump() method.
 
 
Method resolution order:
PicklingError
PickleError
exceptions.Exception
exceptions.BaseException
__builtin__.object

Data descriptors inherited from PickleError:
__weakref__
list of weak references to the object (if defined)

Methods inherited from exceptions.Exception:
__init__(...)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Data and other attributes inherited from exceptions.Exception:
__new__ = <built-in method __new__ of type object at 0x8125440>
T.__new__(S, ...) -> a new object with type S, a subtype of T

Methods inherited from exceptions.BaseException:
__delattr__(...)
x.__delattr__('name') <==> del x.name
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__getitem__(...)
x.__getitem__(y) <==> x[y]
__getslice__(...)
x.__getslice__(i, j) <==> x[i:j]
 
Use of negative indices is not supported.
__reduce__(...)
__repr__(...)
x.__repr__() <==> repr(x)
__setattr__(...)
x.__setattr__('name', value) <==> x.name = value
__setstate__(...)
__str__(...)
x.__str__() <==> str(x)

Data descriptors inherited from exceptions.BaseException:
__dict__
args
message
exception message

 
class Unpickler
     Methods defined here:
__init__(self, file)
This takes a file-like object for reading a pickle data stream.
 
The protocol version of the pickle is detected automatically, so no
proto argument is needed.
 
The file-like object must have two methods, a read() method that
takes an integer argument, and a readline() method that requires no
arguments.  Both methods should return a string.  Thus file-like
object can be a file object opened for reading, a StringIO object,
or any other custom object that meets this interface.
find_class(self, module, name)
get_extension(self, code)
load(self)
Read a pickled object representation from the open file.
 
Return the reconstituted object hierarchy specified in the file.
load_append(self)
load_appends(self)
load_binfloat(self, unpack=<function unpack at 0xb716dbfc>)
load_binget(self)
load_binint(self)
load_binint1(self)
load_binint2(self)
load_binpersid(self)
load_binput(self)
load_binstring(self)
load_binunicode(self)
load_build(self)
load_dict(self)
load_dup(self)
load_empty_dictionary(self)
load_empty_list(self)
load_empty_tuple(self)
load_eof(self)
load_ext1(self)
load_ext2(self)
load_ext4(self)
load_false(self)
load_float(self)
load_get(self)
load_global(self)
load_inst(self)
load_int(self)
load_list(self)
load_long(self)
load_long1(self)
load_long4(self)
load_long_binget(self)
load_long_binput(self)
load_mark(self)
load_newobj(self)
load_none(self)
load_obj(self)
load_persid(self)
load_pop(self)
load_pop_mark(self)
load_proto(self)
load_put(self)
load_reduce(self)
load_setitem(self)
load_setitems(self)
load_short_binstring(self)
load_stop(self)
load_string(self)
load_true(self)
load_tuple(self)
load_tuple1(self)
load_tuple2(self)
load_tuple3(self)
load_unicode(self)
marker(self)
# Return largest index k such that self.stack[k] is self.mark.
# If the stack doesn't contain a mark, eventually raises IndexError.
# This could be sped by maintaining another stack, of indices at which
# the mark appears.  For that matter, the latter stack would suffice,
# and we wouldn't need to push mark objects on self.stack at all.
# Doing so is probably a good thing, though, since if the pickle is
# corrupt (or hostile) we may get a clue from finding self.mark embedded
# in unpickled objects.

Data and other attributes defined here:
dispatch = {'': <function load_eof at 0xb6e6080c>, '(': <function load_mark at 0xb6e6b454>, ')': <function load_empty_tuple at 0xb6e60cdc>, '.': <function load_stop at 0xb6e6b48c>, '0': <function load_pop at 0xb6e6b144>, '1': <function load_pop_mark at 0xb6e6b17c>, '2': <function load_dup at 0xb6e6b1b4>, 'F': <function load_float at 0xb6e60b1c>, 'G': <function load_binfloat at 0xb6e60b54>, 'I': <function load_int at 0xb6e60994>, ...}

 
class UnpicklingError(PickleError)
    This exception is raised when there is a problem unpickling an object,
such as a security violation.
 
Note that other exceptions may also be raised during unpickling, including
(but not necessarily limited to) AttributeError, EOFError, ImportError,
and IndexError.
 
 
Method resolution order:
UnpicklingError
PickleError
exceptions.Exception
exceptions.BaseException
__builtin__.object

Data descriptors inherited from PickleError:
__weakref__
list of weak references to the object (if defined)

Methods inherited from exceptions.Exception:
__init__(...)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Data and other attributes inherited from exceptions.Exception:
__new__ = <built-in method __new__ of type object at 0x8125440>
T.__new__(S, ...) -> a new object with type S, a subtype of T

Methods inherited from exceptions.BaseException:
__delattr__(...)
x.__delattr__('name') <==> del x.name
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__getitem__(...)
x.__getitem__(y) <==> x[y]
__getslice__(...)
x.__getslice__(i, j) <==> x[i:j]
 
Use of negative indices is not supported.
__reduce__(...)
__repr__(...)
x.__repr__() <==> repr(x)
__setattr__(...)
x.__setattr__('name', value) <==> x.name = value
__setstate__(...)
__str__(...)
x.__str__() <==> str(x)

Data descriptors inherited from exceptions.BaseException:
__dict__
args
message
exception message

 
Functions
       
dump(obj, file, protocol=None)
dumps(obj, protocol=None)
load(file)
loads(str)

 
Data
        APPEND = 'a'
APPENDS = 'e'
BINFLOAT = 'G'
BINGET = 'h'
BININT = 'J'
BININT1 = 'K'
BININT2 = 'M'
BINPERSID = 'Q'
BINPUT = 'q'
BINSTRING = 'T'
BINUNICODE = 'X'
BUILD = 'b'
DICT = 'd'
DUP = '2'
EMPTY_DICT = '}'
EMPTY_LIST = ']'
EMPTY_TUPLE = ')'
EXT1 = '\x82'
EXT2 = '\x83'
EXT4 = '\x84'
FALSE = 'I00\n'
FLOAT = 'F'
GET = 'g'
GLOBAL = 'c'
HIGHEST_PROTOCOL = 2
INST = 'i'
INT = 'I'
LIST = 'l'
LONG = 'L'
LONG1 = '\x8a'
LONG4 = '\x8b'
LONG_BINGET = 'j'
LONG_BINPUT = 'r'
MARK = '('
NEWFALSE = '\x89'
NEWOBJ = '\x81'
NEWTRUE = '\x88'
NONE = 'N'
OBJ = 'o'
PERSID = 'P'
POP = '0'
POP_MARK = '1'
PROTO = '\x80'
PUT = 'p'
REDUCE = 'R'
SETITEM = 's'
SETITEMS = 'u'
SHORT_BINSTRING = 'U'
STOP = '.'
STRING = 'S'
TRUE = 'I01\n'
TUPLE = 't'
TUPLE1 = '\x85'
TUPLE2 = '\x86'
TUPLE3 = '\x87'
UNICODE = 'V'
__all__ = ['PickleError', 'PicklingError', 'UnpicklingError', 'Pickler', 'Unpickler', 'dump', 'dumps', 'load', 'loads', 'APPEND', 'APPENDS', 'BINFLOAT', 'BINGET', 'BININT', 'BININT1', 'BININT2', 'BINPERSID', 'BINPUT', 'BINSTRING', 'BINUNICODE', ...]
__version__ = '$Revision: 38432 $'