@@ -107,11 +107,47 @@ Programmatic interface
107107.. function :: genops(pickle)
108108
109109 Provides an :term: `iterator ` over all of the opcodes in a pickle, returning a
110- sequence of ``(opcode, arg, pos) `` triples. *opcode * is an instance of an
111- :class: `OpcodeInfo ` class ; *arg * is the decoded value, as a Python object, of
112- the opcode's argument; *pos * is the position at which this opcode is located.
110+ sequence of ``(opcode, arg, pos) `` triples. *opcode * is an instance of
111+ :class: `OpcodeInfo `; *arg * is the decoded value, as a Python object, of the
112+ opcode's argument; *pos * is the position at which this opcode is located.
113113 *pickle * can be a string or a file-like object.
114114
115+ .. class :: OpcodeInfo
116+
117+ Represents information about a pickle opcode.
118+
119+ Instances of this class are returned as the first element of the tuples
120+ yielded by :func: `genops `.
121+
122+ .. attribute :: name
123+
124+ The symbolic name of the opcode.
125+
126+ .. attribute :: code
127+
128+ The one-character opcode value.
129+
130+ .. attribute :: arg
131+
132+ The descriptor for the opcode argument, or ``None `` if the opcode has
133+ no argument.
134+
135+ .. attribute :: stack_before
136+
137+ A list describing the stack before the opcode executes.
138+
139+ .. attribute :: stack_after
140+
141+ A list describing the stack after the opcode executes.
142+
143+ .. attribute :: proto
144+
145+ The pickle protocol version in which the opcode was introduced.
146+
147+ .. attribute :: doc
148+
149+ A human-readable description of the opcode.
150+
115151.. function :: optimize(picklestring)
116152
117153 Returns a new equivalent pickle string after eliminating unused ``PUT ``
0 commit comments