Pickle

Hi,

Can Root objects be pickled (i.e. using the python pickle module). I tried with a histo but it gives me an error.

Obviously you can save the histo to a root file anyway, I’m just curious.

Karol.

Karol,

it would have suprised me if it had worked. But IIRC, someone told me once that he wrote an extension to make it work. I’ll ask again.

Cheers,
Wim

Karol,

this from Scott:[quote]Sort of, but not exactly. The root objects aren’t actually converted
to pickle format. Instead, the root objects get saved to a root file,
as usual, and in addition, a python pickle string is stuffed into the
root file. This pickle string can contain references to the root objects
in the file. So the upshot is that in pyroot, you can take a python
structure which holds references to root objects and save the whole
mess to a root file, and then later read it back, including the python
part. But what you have is a root file (that contains a pickle) and
not a pickle file — this has the advantage that it can be read
directly with root if you want, ignoring the python part.

Anyway, the code’s in root_pickle.py, see: http://alxr.usatlas.bnl.gov/lxr/source/atlas/PhysicsAnalysis/PyAnalysis/PyAnalysisUtils/python/root_pickle.py.[/quote]
HTH,
Wim

Hi,

just checked in code into SVN that allow pickling of ROOT objects.

Cheers,
Wim

Cool!