[Numpy-discussion] Fwd: Pull request #3188 - Void scalar pickling behavior.

Nathaniel Smith njs@pobox....
Sat Apr 6 15:45:36 CDT 2013

On Sat, Apr 6, 2013 at 8:03 PM, Alex Ford <fordas@uw.edu> wrote:
> Hello,
> Do any core developers or uses have guidance on how to resolve PR #3188
> (https://github.com/numpy/numpy/pull/3188) in relation to the pickling
> behavior of array scalar objects?
> To summarize, pickling array scalars with object fields, which are produced
> when indexing record arrays with object fields, stores the object address
> instead of pickling the referenced object. This behavior, obviously, results
> in invalid references on unpickling.
> Two current options are to:
> A) Raise an exception on pickling scalars with object fields.
> B) Transparently convert scalars to zero-rank arrays on pickling, which
> pickle properly.
> Unless there are objections or opinions on potential solutions, I am
> inclined to implement A.

Option (A) would certainly be an improvement over silently saving
corrupted data!

I guess the best would be to implement proper pickling -- which might
be as simple as writing a pickle function that casts to a zero-rank
array and saves that, and an unpickler that casts back. But I don't
know if it's worth spending much effort on -- people haven't exactly
been clamoring for this functionality that I've noticed.


More information about the NumPy-Discussion mailing list