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
dfb64076
Commit
dfb64076
authored
Jan 27, 2003
by
Tim Peters
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added a brief comment to each pickle opcode declaration.
parent
bcbb2060
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
45 deletions
+50
-45
Lib/pickle.py
Lib/pickle.py
+50
-45
No files found.
Lib/pickle.py
View file @
dfb64076
...
...
@@ -2,6 +2,7 @@
See module cPickle for a (much) faster implementation.
See module copy_reg for a mechanism for registering custom picklers.
See module pickletools source for extensive comments.
Classes:
...
...
@@ -77,50 +78,54 @@ try:
except
NameError
:
UnicodeType
=
None
MARK
=
'('
STOP
=
'.'
POP
=
'0'
POP_MARK
=
'1'
DUP
=
'2'
FLOAT
=
'F'
INT
=
'I'
BININT
=
'J'
BININT1
=
'K'
LONG
=
'L'
BININT2
=
'M'
NONE
=
'N'
PERSID
=
'P'
BINPERSID
=
'Q'
REDUCE
=
'R'
STRING
=
'S'
BINSTRING
=
'T'
SHORT_BINSTRING
=
'U'
UNICODE
=
'V'
BINUNICODE
=
'X'
APPEND
=
'a'
BUILD
=
'b'
GLOBAL
=
'c'
DICT
=
'd'
EMPTY_DICT
=
'}'
APPENDS
=
'e'
GET
=
'g'
BINGET
=
'h'
INST
=
'i'
LONG_BINGET
=
'j'
LIST
=
'l'
EMPTY_LIST
=
']'
OBJ
=
'o'
PUT
=
'p'
BINPUT
=
'q'
LONG_BINPUT
=
'r'
SETITEM
=
's'
TUPLE
=
't'
EMPTY_TUPLE
=
')'
SETITEMS
=
'u'
BINFLOAT
=
'G'
TRUE
=
'I01
\
n
'
FALSE
=
'I00
\
n
'
# Pickle opcodes. See pickletools.py for extensive docs. The listing
# here is in kind-of alphabetical order of 1-character pickle code.
# pickletools groups them by purpose.
MARK
=
'('
# push special markobject on stack
STOP
=
'.'
# every pickle ends with STOP
POP
=
'0'
# discard topmost stack item
POP_MARK
=
'1'
# discard stack top through topmost markobject
DUP
=
'2'
# duplicate top stack item
FLOAT
=
'F'
# push float object; decimal string argument
INT
=
'I'
# push integer or bool; decimal string argument
BININT
=
'J'
# push four-byte signed int
BININT1
=
'K'
# push 1-byte unsigned int
LONG
=
'L'
# push long; decimal string argument
BININT2
=
'M'
# push 2-byte unsigned int
NONE
=
'N'
# push None
PERSID
=
'P'
# push persistent object; id is taken from string arg
BINPERSID
=
'Q'
# " " " ; " " " " stack
REDUCE
=
'R'
# apply callable to argtuple, both on stack
STRING
=
'S'
# push string; NL-terminated string argument
BINSTRING
=
'T'
# push string; counted binary string argument
SHORT_BINSTRING
=
'U'
# " " ; " " " " < 256 bytes
UNICODE
=
'V'
# push Unicode string; raw-unicode-escaped'd argument
BINUNICODE
=
'X'
# " " " ; counted UTF-8 string argument
APPEND
=
'a'
# append stack top to list below it
BUILD
=
'b'
# call __setstate__ or __dict__.update()
GLOBAL
=
'c'
# push self.find_class(modname, name); 2 string args
DICT
=
'd'
# build a dict from stack items
EMPTY_DICT
=
'}'
# push empty dict
APPENDS
=
'e'
# extend list on stack by topmost stack slice
GET
=
'g'
# push item from memo on stack; index is string arg
BINGET
=
'h'
# " " " " " " ; " " 1-byte arg
INST
=
'i'
# build & push class instance
LONG_BINGET
=
'j'
# push item from memo on stack; index is 4-byte arg
LIST
=
'l'
# build list from topmost stack items
EMPTY_LIST
=
']'
# push empty list
OBJ
=
'o'
# build & push class instance
PUT
=
'p'
# store stack top in memo; index is string arg
BINPUT
=
'q'
# " " " " " ; " " 1-byte arg
LONG_BINPUT
=
'r'
# " " " " " ; " " 4-byte arg
SETITEM
=
's'
# add key+value pair to dict
TUPLE
=
't'
# build tuple from topmost stack items
EMPTY_TUPLE
=
')'
# push empty tuple
SETITEMS
=
'u'
# modify dict by adding topmost key+value pairs
BINFLOAT
=
'G'
# push float; arg is 8-byte float encoding
TRUE
=
'I01
\
n
'
# not an opcode; see INT docs in pickletools.py
FALSE
=
'I00
\
n
'
# not an opcode; see INT docs in pickletools.py
__all__
.
extend
([
x
for
x
in
dir
()
if
re
.
match
(
"[A-Z][A-Z0-9_]+$"
,
x
)])
...
...
@@ -303,7 +308,7 @@ class Pickler:
if
not
callable
(
acallable
):
raise
PicklingError
(
"__reduce__() must return callable as "
"first argument, not %s"
%
`acallable`
)
save
(
acallable
)
save
(
arg_tup
)
write
(
REDUCE
)
...
...
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