Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 39 additions & 3 deletions Doc/library/pickletools.rst
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,47 @@ Programmatic interface
.. function:: genops(pickle)

Provides an :term:`iterator` over all of the opcodes in a pickle, returning a
sequence of ``(opcode, arg, pos)`` triples. *opcode* is an instance of an
:class:`OpcodeInfo` class; *arg* is the decoded value, as a Python object, of
the opcode's argument; *pos* is the position at which this opcode is located.
sequence of ``(opcode, arg, pos)`` triples. *opcode* is an instance of
:class:`OpcodeInfo`; *arg* is the decoded value, as a Python object, of the
Comment thread
BHUVANSH855 marked this conversation as resolved.
opcode's argument; *pos* is the position at which this opcode is located.
*pickle* can be a string or a file-like object.

.. class:: OpcodeInfo

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't in pickletools.__all__ so if we're documenting it we should add it there, and also ArgumentDescriptor and StackObject. They are technically already public per PEP 387, and we do return them, so I think we should expose them properly.


Represents information about a pickle opcode.

Instances of this class are returned as the first element of the tuples
yielded by :func:`genops`.

.. attribute:: name

The symbolic name of the opcode.

.. attribute:: code

The one-character opcode value.

.. attribute:: arg

The descriptor for the opcode argument, or ``None`` if the opcode has
no argument.

.. attribute:: stack_before

A list describing the stack before the opcode executes.

.. attribute:: stack_after

A list describing the stack after the opcode executes.

.. attribute:: proto

The pickle protocol version in which the opcode was introduced.

.. attribute:: doc

A human-readable description of the opcode.

.. function:: optimize(picklestring)

Returns a new equivalent pickle string after eliminating unused ``PUT``
Expand Down
1 change: 0 additions & 1 deletion Doc/tools/.nitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ Doc/library/lzma.rst
Doc/library/mmap.rst
Doc/library/multiprocessing.rst
Doc/library/optparse.rst
Doc/library/pickletools.rst
Doc/library/pyexpat.rst
Doc/library/select.rst
Doc/library/socket.rst
Expand Down
Loading