[Numpy-discussion] Deserialized arrays with base mutate strings
Pauli Virtanen
pav at iki.fi
Wed Sep 23 14:59:08 EDT 2009
ke, 2009-09-23 kello 10:01 +0200, Hrvoje Niksic kirjoitti:
[clip]
> I guess this one could be prevented by verifying that the buffer is
> writable when setting the "writable" flag. When deserializing arrays, I
> don't see a reason for the "base" property to even exist - sharing of
> the buffer between different views is unpreserved anyway, as reported in
> my other thread.
IIRC, it avoids one copy: ndarray.__reduce__ pickles the raw data as a
string, and so ndarray.__setstate__ receives a Python string back.
I don't remember if it's in the end possible to emit raw byte stream to
a pickle somehow, not going through strings. If not, then a copy can't
be avoided.
--
Pauli Virtanen
More information about the NumPy-Discussion
mailing list