[NumPy-Tickets] [NumPy] #1452: pickle memmap'd arrays (patch + tests)
NumPy Trac
numpy-tickets@scipy....
Mon May 3 22:37:19 CDT 2010
#1452: pickle memmap'd arrays (patch + tests)
-------------------------+--------------------------------------------------
Reporter: brentp | Owner: somebody
Type: enhancement | Status: needs_review
Priority: normal | Milestone:
Component: Other | Version:
Keywords: |
-------------------------+--------------------------------------------------
Comment(by charris):
I think I'll just apply the previous patch. Because there is no
__setstate__ this bit from the docs worries me:
{{{
object.__setstate__()
Upon unpickling, if the class also defines the method __setstate__(),
it is
called with the unpickled state. [5] If there is no __setstate__() method,
the
pickled state must be a dictionary and its items are assigned to the new
instance’s
dictionary. If a class defines both __getstate__() and __setstate__(), the
state
object needn’t be a dictionary and these methods can do what they want.
[6]
}}}
However, now I'm dubious about __getslice__, the problem being when the
mmap is created with an offset:
{{{
if sys.version_info[:2] >= (2,6):
# The offset keyword in mmap.mmap needs Python >= 2.6
start = offset - offset % mmap.ALLOCATIONGRANULARITY
bytes -= start
offset -= start
mm = mmap.mmap(fid.fileno(), bytes, access=acc, offset=start)
else:
mm = mmap.mmap(fid.fileno(), bytes, access=acc)
}}}
So the offset that works on the already mmapped file may not work with the
file mmapped after unpickling, it looks like you may need the value of the
start variable also. I don't think this is going to play well with the
current version of __new__, although I think you could do it with __init__
and the get/set state stuff. It is also possible that this will ruin
portability of the pickled objects between python versions/operating
systems, but I suppose we can live with that. Thoughts?
--
Ticket URL: <http://projects.scipy.org/numpy/ticket/1452#comment:6>
NumPy <http://projects.scipy.org/numpy>
My example project
More information about the NumPy-Tickets
mailing list