[Numpy-discussion] Deserialized arrays with base mutate strings
Wed Sep 23 14:02:49 CDT 2009
On Wed, Sep 23, 2009 at 13:59, Pauli Virtanen <email@example.com> wrote:
> ke, 2009-09-23 kello 10:01 +0200, Hrvoje Niksic kirjoitti:
>> 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.
Correct, that was the goal.
> 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.
No, I don't think you can.
"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
-- Umberto Eco
More information about the NumPy-Discussion