bigarray: ArrayRef utility
ArrayRef is a reference to NumPy array.
The reference is represented by root array object and instructions how to create original array as some view of the root.
Such reference could be useful in situations where one needs to pass arrays between processes and instead of copying array data, leverage the fact that top-level array, for example ZBigArray, is already persisted separately, and only send small amount of information referencing data in question.
Use ArrayRef(array)
to create reference to an ndarray.
Use .deref()
to convert ArrayRef to pointed array object.
NOTE
don't send ArrayRef unconditionally - for example when array object is small regular ndarray with also regular, but big, root ndarray, sending ArrayRef will send whole data for root object, not for small leaf.
Sending ArrayRef only makes sense when root object is known to be already persisted by other means, for example something like below in ZODB context:
aref = ArrayRef(a)
if isinstance(aref.root, Persistent):
send aref
else:
send a
Please see individual patches for more details.