Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(347)

#15642: Integrate pickle protocol version 4 GSoC work by Stefan Mihaila

Can't Edit
Can't Publish+Mail
Start Review
Created:
9 months, 1 week ago by alexandre
Modified:
1 week, 5 days ago
Reviewers:
mstefanro, pitrou
CC:
jcea, AntoinePitrou, Alexandre Vassalotti, asvetlov, storchaka, Stefan M
Visibility:
Public.

Patch Set 1 #

Total comments: 118

Patch Set 2 #

Total comments: 11

Patch Set 3 #

Unified diffs Side-by-side diffs Delta from patch set Stats Patch
Doc/library/operator.rst View 1 2 1 chunk +0 lines, -3 lines 0 comments Download
Lib/copyreg.py View 1 2 1 chunk +6 lines, -0 lines 0 comments Download
Lib/pickle.py View 1 2 35 chunks +840 lines, -97 lines 0 comments Download
Lib/pickletools.py View 1 2 85 chunks +731 lines, -27 lines 0 comments Download
Lib/test/pickletester.py View 1 2 9 chunks +1086 lines, -3 lines 0 comments Download
Lib/test/test_pickletools.py View 1 2 1 chunk +2 lines, -0 lines 0 comments Download
Modules/_pickle.c View 1 2 70 chunks +1315 lines, -218 lines 0 comments Download
Objects/setobject.c View 1 2 5 chunks +148 lines, -26 lines 0 comments Download
Objects/typeobject.c View 1 2 4 chunks +60 lines, -7 lines 0 comments Download
PCbuild/build.bat View 1 2 1 chunk +28 lines, -4 lines 0 comments Download

Messages

Total messages: 10
Alexandre Vassalotti
Hi Stefan, I have started reviewing your implementation of pickle protocol 4. There is a ...
9 months, 1 week ago #1
Stefan M
http://bugs.python.org/review/15642/diff/5733/Lib/pickle.py File Lib/pickle.py (right): http://bugs.python.org/review/15642/diff/5733/Lib/pickle.py#newcode58 Lib/pickle.py:58: def _t(self, func): #used for pickling methods with REDUCE ...
9 months, 1 week ago #2
Alexandre Vassalotti
http://bugs.python.org/review/15642/diff/5733/Lib/pickle.py File Lib/pickle.py (right): http://bugs.python.org/review/15642/diff/5733/Lib/pickle.py#newcode58 Lib/pickle.py:58: def _t(self, func): #used for pickling methods with REDUCE ...
9 months, 1 week ago #3
Stefan M
http://bugs.python.org/review/15642/diff/5733/Lib/pickle.py File Lib/pickle.py (right): http://bugs.python.org/review/15642/diff/5733/Lib/pickle.py#newcode320 Lib/pickle.py:320: raise On 2012/08/14 19:20:23, Alexandre Vassalotti wrote: > On ...
9 months, 1 week ago #4
AntoinePitrou
On 2012/08/17 15:18:23, Stefan M wrote: > > But network errors are typically handled at ...
9 months, 1 week ago #5
Stefan M
Fixed some of the stuff suggested in the comments. I don't know how to add ...
9 months, 1 week ago #6
Alexandre Vassalotti
If you upload the diff of your fork against the main repo on the bug, ...
9 months, 1 week ago #7
Stefan M
http://bugs.python.org/review/15642/diff/5733/Lib/pickle.py File Lib/pickle.py (right): http://bugs.python.org/review/15642/diff/5733/Lib/pickle.py#newcode26 Lib/pickle.py:26: __version__ = "$Revision$" # Code version On 2012/08/14 07:33:25, ...
9 months, 1 week ago #8
Alexandre Vassalotti
http://bugs.python.org/review/15642/diff/5733/Lib/pickle.py File Lib/pickle.py (right): http://bugs.python.org/review/15642/diff/5733/Lib/pickle.py#newcode60 Lib/pickle.py:60: def _isclassmethod(func): Ohhh, I probably used Python 2.x when ...
9 months ago #9
Stefan M
9 months ago #10
http://bugs.python.org/review/15642/diff/5733/Lib/pickle.py
File Lib/pickle.py (right):

http://bugs.python.org/review/15642/diff/5733/Lib/pickle.py#newcode212
Lib/pickle.py:212: SEMISHORT_BINUNICODE = b'\x8d'
On 2012/08/14 07:33:25, Alexandre Vassalotti wrote:
> Why not BINUNICODE16?

Done.

http://bugs.python.org/review/15642/diff/5733/Lib/pickle.py#newcode215
Lib/pickle.py:215: SEMISHORT_BINBYTES   = b'\x90'
On 2012/08/14 07:33:25, Alexandre Vassalotti wrote:
> Same thing here.

Done.

http://bugs.python.org/review/15642/diff/5733/Lib/pickle.py#newcode351
Lib/pickle.py:351: # "memos" in pickletools indicate which opcodes memoize (for
debugging)
On 2012/08/21 23:43:04, Alexandre Vassalotti wrote:
> OK, I see what you meant now. Can you clarify your comment with your new
> explanation? 

Done.

http://bugs.python.org/review/15642/diff/5733/Lib/pickle.py#newcode386
Lib/pickle.py:386: 
On 2012/08/14 07:33:25, Alexandre Vassalotti wrote:
> Why not raise an exception instead when this happens?

Removed.

http://bugs.python.org/review/15642/diff/5733/Lib/pickle.py#newcode530
Lib/pickle.py:530: raise PicklingError('When pickling a reduced object, '
On 2012/08/14 07:33:25, Alexandre Vassalotti wrote:
> The term "reduced object" is confusing. I think we should say:
> 
>    When pickling an object via the reduce protocol...

Done.

http://bugs.python.org/review/15642/diff/5733/Lib/pickle.py#newcode865
Lib/pickle.py:865: # dict.fromkeys is dict.fromkeys = False
On 2012/08/21 23:43:04, Alexandre Vassalotti wrote:
> Yes.
> 
> I admit the behaviour of the 'is' operator is really counter-intuitive here,
> since
> 
> >>> id(dict.fromkeys) == id(dict.fromkeys)
> True
> 
> Maybe you should open a bug about it.

Added the new comment.

Also, created an issue at http://bugs.python.org/issue15773

http://bugs.python.org/review/15642/diff/5733/Lib/pickle.py#newcode964
Lib/pickle.py:964: return self._RefuseDispatchedSave()
On 2012/08/14 07:33:25, Alexandre Vassalotti wrote:
> I think it would be better to just call save_reduce directly here.

Done.

http://bugs.python.org/review/15642/diff/5733/Lib/pickle.py#newcode974
Lib/pickle.py:974: for i, el in enumerate(obj):
On 2012/08/14 07:33:25, Alexandre Vassalotti wrote:
> Use more descriptive names for bs and el

Well, bs is merely a shorthand alias for self._BATCHSIZE so I won't have to type
it over and over. I could remove bs and use self._BATCHSIZE directly if you
will.

http://bugs.python.org/review/15642/diff/5733/Lib/pickle.py#newcode974
Lib/pickle.py:974: for i, el in enumerate(obj):
On 2012/08/14 07:33:25, Alexandre Vassalotti wrote:
> And why follow what batch_appends and batch_setitems do?

I assume you meant why not follow.

Well, I didn't really look at the implementation for _batch_appends when I wrote
this, but I don't see an advantage of that approach over this one.

I could move the code into a _batch_set for consistency.
Also, I could mirror the _batch_appends implementation if you consider it
matters. However, that implementation uses an additional temporary container to
store each batch, so it's probably less efficient. Mine could be optimized a
little if we would choose a BATCHSIZE which is a power of 2. That way computing
the modulo is nearly a noop.

http://bugs.python.org/review/15642/diff/5733/Lib/pickle.py#newcode1007
Lib/pickle.py:1007: # Here follows the technique which is also used in
save_tuple. Both
On 2012/08/14 07:33:25, Alexandre Vassalotti wrote:
> Here we follow.

Done.

http://bugs.python.org/review/15642/diff/5733/Lib/pickle.py#newcode1009
Lib/pickle.py:1009: # memoized until they are filled. This also means that they
can't be
On 2012/08/14 07:33:25, Alexandre Vassalotti wrote:
> What is filled?

Modified the explanation a bit.

http://bugs.python.org/review/15642/diff/5733/Lib/pickle.py#newcode1011
Lib/pickle.py:1011: # e.g.: a=A(); fs=frozenset([a]); a.fs = fs
On 2012/08/14 07:33:25, Alexandre Vassalotti wrote:
> Format your example.

Done.

http://bugs.python.org/review/15642/diff/5733/Lib/pickle.py#newcode1073
Lib/pickle.py:1073: ret = module
On 2012/08/14 07:33:25, Alexandre Vassalotti wrote:
> Have compared your method with the one posted on issue 13520?
> 
> http://bugs.python.org/issue13520

Just took a quick look now, it appears they are trying to work with __name__ and
if that's not working they fall back to __qualname__. My approach tries
__qualname__ directly.

They argue that their approach has a certain advantage upon looking at the
comments, but I'm not sure that's the case. I'll consider this more carefully
soon.

http://bugs.python.org/review/15642/diff/5733/Lib/pickle.py#newcode1074
Lib/pickle.py:1074: for n in name.split('.'):
On 2012/08/14 07:33:25, Alexandre Vassalotti wrote:
> Use more descriptive name for 'n' 

Done.

http://bugs.python.org/review/15642/diff/5733/Lib/pickle.py#newcode1333
Lib/pickle.py:1333: def load_string(self):
On 2012/08/21 23:43:04, Alexandre Vassalotti wrote:
> Ok I see.
> 
> Can you add your explanation as a comment?

I've added it for now, but I'm not sure load_string is the best place to add
this comment, since it is not the only opcode in this situation. All obsolete
opcodes are.
Sign in to reply to this message.

RSS Feeds Recent Issues | This issue
This is Rietveld cbc36f91f3f7