FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-127413: allow to show specialized bytecode via `dis` CLI by picnixz · Pull Request #127414 · python/cpython · GitHub

/ cpython Public
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) .rst  (3) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
8 changes: 7 additions & 1 deletion Doc/library/dis.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ interpreter.
The :option:`-P <dis --show-positions>` command-line option
and the ``show_positions`` argument were added.

The :option:`-S <dis --specialized>` command-line option is added.

Example: Given the function :func:`!myfunc`::

def myfunc(alist):
Expand Down Expand Up @@ -89,7 +91,7 @@ The :mod:`dis` module can be invoked as a script from the command line:

.. code-block:: sh

python -m dis [-h] [-C] [-O] [-P] [infile]
python -m dis [-h] [-C] [-O] [-P] [-S] [infile]

The following options are accepted:

Expand All @@ -111,6 +113,10 @@ The following options are accepted:

Show positions of instructions in the source code.

.. cmdoption:: -S, --specialized

Show specialized bytecode.

If :file:`infile` is specified, its disassembled code will be written to stdout.
Otherwise, disassembly is performed on compiled source code received from stdin.

Expand Down
6 changes: 6 additions & 0 deletions Doc/whatsnew/3.14.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -348,12 +348,18 @@ dis
This feature is also exposed via :option:`dis --show-positions`.
(Contributed by Bénédikt Tran in :gh:`123165`.)

* Add the :option:`dis --specialized` command-line option to
show specialized bytecode.
(Contributed by Bénédikt Tran in :gh:`127413`.)


errno
-----

* Add :data:`errno.EHWPOISON` error code.
(Contributed by James Roy in :gh:`126585`.)


Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

This line was added after I fixed the conflict. Since we put two blank lines between sections, I think it's ok to keep but I can revert it.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

(At some point, we'll need a copy-edit because the above sections are not splitted with double lines while the sections below are... But since most of the sections have two blank lines, it's easier to add them to places that lack them).

fractions
---------

Expand Down
5 changes: 4 additions & 1 deletion Lib/dis.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -1125,6 +1125,8 @@ def main():
help='show instruction offsets')
parser.add_argument('-P', '--show-positions', action='store_true',
help='show instruction positions')
parser.add_argument('-S', '--specialized', action='store_true',
help='show specialized bytecode')
parser.add_argument('infile', nargs='?', default='-')
args = parser.parse_args()
if args.infile == '-':
Expand All @@ -1135,7 +1137,8 @@ def main():
with open(args.infile, 'rb') as infile:
source = infile.read()
code = compile(source, name, "exec")
dis(code, show_caches=args.show_caches, show_offsets=args.show_offsets, show_positions=args.show_positions)
dis(code, show_caches=args.show_caches, adaptive=args.specialized,
show_offsets=args.show_offsets, show_positions=args.show_positions)

if __name__ == "__main__":
main()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Add the :option:`dis --specialized` command-line option to show specialized
bytecode. Patch by Bénédikt Tran.

Back | FazBrowse Home | New Git URL