gh-127413: allow to show specialized bytecode via dis
CLI (#127414)
This commit is contained in:
parent
fcbe6ecdb6
commit
67b9a5331a
@ -60,6 +60,8 @@ interpreter.
|
|||||||
The :option:`-P <dis --show-positions>` command-line option
|
The :option:`-P <dis --show-positions>` command-line option
|
||||||
and the ``show_positions`` argument were added.
|
and the ``show_positions`` argument were added.
|
||||||
|
|
||||||
|
The :option:`-S <dis --specialized>` command-line option is added.
|
||||||
|
|
||||||
Example: Given the function :func:`!myfunc`::
|
Example: Given the function :func:`!myfunc`::
|
||||||
|
|
||||||
def myfunc(alist):
|
def myfunc(alist):
|
||||||
@ -89,7 +91,7 @@ The :mod:`dis` module can be invoked as a script from the command line:
|
|||||||
|
|
||||||
.. code-block:: sh
|
.. 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:
|
The following options are accepted:
|
||||||
|
|
||||||
@ -111,6 +113,10 @@ The following options are accepted:
|
|||||||
|
|
||||||
Show positions of instructions in the source code.
|
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.
|
If :file:`infile` is specified, its disassembled code will be written to stdout.
|
||||||
Otherwise, disassembly is performed on compiled source code received from stdin.
|
Otherwise, disassembly is performed on compiled source code received from stdin.
|
||||||
|
|
||||||
|
@ -348,12 +348,18 @@ dis
|
|||||||
This feature is also exposed via :option:`dis --show-positions`.
|
This feature is also exposed via :option:`dis --show-positions`.
|
||||||
(Contributed by Bénédikt Tran in :gh:`123165`.)
|
(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
|
errno
|
||||||
-----
|
-----
|
||||||
|
|
||||||
* Add :data:`errno.EHWPOISON` error code.
|
* Add :data:`errno.EHWPOISON` error code.
|
||||||
(Contributed by James Roy in :gh:`126585`.)
|
(Contributed by James Roy in :gh:`126585`.)
|
||||||
|
|
||||||
|
|
||||||
fractions
|
fractions
|
||||||
---------
|
---------
|
||||||
|
|
||||||
|
@ -1125,6 +1125,8 @@ def main():
|
|||||||
help='show instruction offsets')
|
help='show instruction offsets')
|
||||||
parser.add_argument('-P', '--show-positions', action='store_true',
|
parser.add_argument('-P', '--show-positions', action='store_true',
|
||||||
help='show instruction positions')
|
help='show instruction positions')
|
||||||
|
parser.add_argument('-S', '--specialized', action='store_true',
|
||||||
|
help='show specialized bytecode')
|
||||||
parser.add_argument('infile', nargs='?', default='-')
|
parser.add_argument('infile', nargs='?', default='-')
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
if args.infile == '-':
|
if args.infile == '-':
|
||||||
@ -1135,7 +1137,8 @@ def main():
|
|||||||
with open(args.infile, 'rb') as infile:
|
with open(args.infile, 'rb') as infile:
|
||||||
source = infile.read()
|
source = infile.read()
|
||||||
code = compile(source, name, "exec")
|
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__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
@ -0,0 +1,2 @@
|
|||||||
|
Add the :option:`dis --specialized` command-line option to show specialized
|
||||||
|
bytecode. Patch by Bénédikt Tran.
|
Loading…
x
Reference in New Issue
Block a user