SND@LHC Software
|
Classes | |
class | IO_Wrapper |
class | Pickler |
class | ROOT_Proxy |
class | Unpickler |
Functions | |
_protect (s) | |
_restore (s) | |
compat_hooks (hooks) | |
dump (obj, root_file, proto=0, key=None) | |
load (root_file, use_proxy=1, key=None) | |
Variables | |
string_types = basestring, | |
tuple | integer_types = (int, long) |
list | __all__ |
_compat_hooks = None | |
dict | xdict = {} |
int | xserial = 0 |
Pickle python data into a ROOT file, preserving references to ROOT objects. This module allows pickling python objects into a ROOT file. The python objects may contain references to named ROOT objects. If one has set up a structure of python objects to hold ROOT histograms, this provides a convenient way of saving and restoring your histograms. The pickled python data are stored in an additional string object in the ROOT file; any ROOT objects are stored as usual. (Thus, ROOT files written by the pickler can be read just like any other ROOT file if you don't care about the python data.) Here's an example of writing a pickle:: from rootpyPickler import Pickler pkl=Pickler(file) pkl.dump(ShipGeo,'ShipGeo') from rootpyPickler import Unpickler upkl = Unpickler(f) ShipGeo = upkl.load('ShipGeo') The following additional notes apply: * Pickling may not always work correctly for the case of python objects deriving from ROOT objects. It will probably also not work for the case of ROOT objects which do not derive from TObject. * When the pickled data are being read, if a class doesn't exist, a dummy class with no methods will be used instead. This is different from the standard pickle behavior (where it would be an error), but it simplifies usage in the common case where the class is being used to hold histograms, and its methods are entirely concerned with filling the histograms. * When restoring a reference to a ROOT object, the default behavior is to not read the ROOT object itself, but instead to create a proxy. The ROOT object will then be read the first time the proxy is accessed. This can help significantly with time and memory usage if you're only accessing a small fraction of the ROOT objects, but it does mean that you need to keep the ROOT file open. Pass use_proxy=0 to disable this behavior.
|
protected |
Definition at line 91 of file rootpyPickler.py.
|
protected |
Definition at line 95 of file rootpyPickler.py.
rootpyPickler.compat_hooks | ( | hooks | ) |
Set compatibility hooks. If this is set, then hooks[0] is called before loading, and hooks[1] is called after loading. hooks[1] is called with the return value of hooks[0] as an argument. This is useful for backwards compatibility in some situations.
Definition at line 341 of file rootpyPickler.py.
rootpyPickler.dump | ( | obj, | |
root_file, | |||
proto = 0 , |
|||
key = None |
|||
) |
Dump an object into a ROOT TFile. `root_file` may be an open ROOT file or directory, or a string path to an existing ROOT file.
Definition at line 352 of file rootpyPickler.py.
rootpyPickler.load | ( | root_file, | |
use_proxy = 1 , |
|||
key = None |
|||
) |
Load an object from a ROOT TFile. `root_file` may be an open ROOT file or directory, or a string path to an existing ROOT file.
Definition at line 369 of file rootpyPickler.py.
|
private |
Definition at line 68 of file rootpyPickler.py.
|
protected |
Definition at line 75 of file rootpyPickler.py.
tuple rootpyPickler.integer_types = (int, long) |
Definition at line 64 of file rootpyPickler.py.
rootpyPickler.string_types = basestring, |
Definition at line 62 of file rootpyPickler.py.
dict rootpyPickler.xdict = {} |
Definition at line 76 of file rootpyPickler.py.
int rootpyPickler.xserial = 0 |
Definition at line 77 of file rootpyPickler.py.