[issue39681] pickle.load expects an object that implements readinto

Antoine Pitrou report at bugs.python.org
Fri Feb 21 05:04:16 EST 2020


Antoine Pitrou <pitrou at free.fr> added the comment:

Well, in the mmap case, this is trivially fixed by writing:
```
with open("my_data.pkl", "r+b") as f_in:
    mm = mmap.mmap(f_in.fileno(), 0)

print(pickle.loads(memoryview(mm)))
```

It will also be faster this way, since the pickle will be read directly from memory instead of going through read() calls.

This makes me think that perhaps this issue isn't as bad: it forces people to abandon bad idioms :-)

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue39681>
_______________________________________


More information about the Python-bugs-list mailing list