Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
d97da80d
Commit
d97da80d
authored
Jan 28, 2003
by
Tim Peters
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save_tuple(): So long as the charter is rewriting for clarity, the snaky
control flow had to be simplified.
parent
ff57bff1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
21 deletions
+20
-21
Lib/pickle.py
Lib/pickle.py
+20
-21
No files found.
Lib/pickle.py
View file @
d97da80d
...
...
@@ -458,27 +458,26 @@ class Pickler:
def
save_tuple
(
self
,
object
):
write
=
self
.
write
save
=
self
.
save
memo
=
self
.
memo
proto
=
self
.
proto
if
proto
>=
1
:
n
=
len
(
object
)
if
n
<=
3
:
if
not
object
:
write
(
EMPTY_TUPLE
)
return
if
proto
>=
2
:
for
element
in
object
:
save
(
element
)
# Subtle. Same as in the big comment below.
if
id
(
object
)
in
memo
:
get
=
self
.
get
(
memo
[
id
(
object
)][
0
])
write
(
POP
*
n
+
get
)
else
:
write
(
_tuplesize2code
[
n
])
self
.
memoize
(
object
)
return
n
=
len
(
object
)
if
n
==
0
and
proto
:
write
(
EMPTY_TUPLE
)
return
save
=
self
.
save
memo
=
self
.
memo
if
n
<=
3
and
proto
>=
2
:
for
element
in
object
:
save
(
element
)
# Subtle. Same as in the big comment below.
if
id
(
object
)
in
memo
:
get
=
self
.
get
(
memo
[
id
(
object
)][
0
])
write
(
POP
*
n
+
get
)
else
:
write
(
_tuplesize2code
[
n
])
self
.
memoize
(
object
)
return
# proto 0, or proto 1 and tuple isn't empty, or proto > 1 and tuple
# has more than 3 elements.
...
...
@@ -486,7 +485,7 @@ class Pickler:
for
element
in
object
:
save
(
element
)
if
object
and
id
(
object
)
in
memo
:
if
n
and
id
(
object
)
in
memo
:
# Subtle. d was not in memo when we entered save_tuple(), so
# the process of saving the tuple's elements must have saved
# the tuple itself: the tuple is recursive. The proper action
...
...
@@ -498,7 +497,7 @@ class Pickler:
if
proto
:
write
(
POP_MARK
+
get
)
else
:
# proto 0 -- POP_MARK not available
write
(
POP
*
(
len
(
object
)
+
1
)
+
get
)
write
(
POP
*
(
n
+
1
)
+
get
)
return
# No recursion (including the empty-tuple case for protocol 0).
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment