-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bpo-36785: PEP 574 implementation #7076
Conversation
cef20d0
to
8943edf
Compare
Modules/_pickle.c
Outdated
|
||
if (self->readinto == NULL) { | ||
/* Call read() and memcpy */ | ||
/* XXX do we want this fallback? pickle.py doesn't have it */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ogrisel Do you think we need to support "file-like" objects without a readinto() method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have a strong opinion. Are there any such file objects in the standard library? The file-like objects that acts as wrappers for (de)compression algorithms such as GzipFile
seem to support readinto
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There doesn't seem to be any. I'll remove this snippet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, the doc mentions that API contract for file
is only to have read
and readline
, so I'm not sure it's ok to remove the fallback...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was the fallback ever added back? Looks like this came up as a real issue on https://bugs.python.org/issue39681
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the ping. I'll reply on the issue.
c56f2dd
to
745e7be
Compare
Rebased. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doc comments
Doc/library/pickle.rst
Outdated
:class:`io.BytesIO` instance, or any other custom object that meets this | ||
interface. | ||
Arguments *file*, *protocol*, *fix_imports* and *buffer_callback* have | ||
the same meaning as in :class:`Pickler`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like having the redundancy removed, as it reduces cognitive load.
Thanks Terry! I've applied the suggested changes now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is my review, enjoy :-) I don't know well the pickle module, so I mostly checked the doc and basic stuff.
By the way, I really like the overall change and the PEP: it's a great enhancement, thanks!
|
||
:class:`PickleBuffer` objects can only be serialized using pickle | ||
protocol 5 or higher. They are eligible for | ||
:ref:`out-of-band serialization <pickle-oob>`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add a reference to your PEP?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is referenced at the end of the "Out-of-band Buffers" section. Since it's quite specialized, I'm not sure it's useful to mention it also here.
Thanks for the review @vstinner. I think I've addressed your comments now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I didn't see any major issue, but I didn't review carefully the C code. Nice PEP, nice implementation, thanks ;-)
I'm gonna merge soon since no other review came and 3.8b1 is due next Friday. |
https://bugs.python.org/issue36785