uproot.pyroot.pyroot_to_buffer

Defined in uproot.pyroot on line 70.

uproot.pyroot.pyroot_to_buffer(obj)
Parameters:

obj (PyROOT object inheriting from TObject) – PyROOT object to serialize.

Serializes a PyROOT object into a NumPy array that is owned by this function.

This function is not thread-safe and the output buffer gets overwritten by the next call to this function. It is essential for callers to copy the data out of the returned buffer, perhaps by calling uproot._util.tobytes on it or by assigning it into another array.

A lock is provided for safety: callers should always call this function within the lock’s context:

with pyroot_to_buffer.lock:
    return uproot._util.tobytes(pyroot_to_buffer(obj))