Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
0bce6e74
Kaydet (Commit)
0bce6e74
authored
Ock 07, 2014
tarafından
R David Murray
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
whatsnew: expand 'dis' entry.
Also add one missing versionadded.
üst
985b8dbe
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
8 deletions
+52
-8
dis.rst
Doc/library/dis.rst
+2
-0
3.4.rst
Doc/whatsnew/3.4.rst
+50
-8
No files found.
Doc/library/dis.rst
Dosyayı görüntüle @
0bce6e74
...
...
@@ -40,6 +40,8 @@ the following command can be used to display the disassembly of
Bytecode analysis
-----------------
.. versionadded:: 3.4
The bytecode analysis API allows pieces of Python code to be wrapped in a
:class:`Bytecode` object that provides easy access to details of the
compiled code.
...
...
Doc/whatsnew/3.4.rst
Dosyayı görüntüle @
0bce6e74
...
...
@@ -558,15 +558,57 @@ differences between single use, reusable and reentrant context managers.
dis
---
Functions :func:`~dis.show_code`, :func:`~dis.dis`, :func:`~dis.distb`, and
:func:`~dis.disassemble` now accept a keyword-only *file* argument that
controls where they write their output.
The :mod:`dis` module is now built around an :class:`~dis.Instruction` class
that provides details of individual bytecode operations and a
:func:`~dis.get_instructions` iterator that emits the Instruction stream for a
given piece of Python code. The various display tools in the :mod:`dis`
module have been updated to be based on these new components.
The new :class:`dis.Bytecode` class provides an object-oriented API for
inspecting bytecode, both in human-readable form and for iterating over
instructions.
that provides object oriented access to the details of each individual bytecode
operation.
A new method, :func:`~dis.get_instructions`, provides an iterator that emits
the Instruction stream for a given piece of Python code. Thus it is now
possible to write a program that inspects and manipulates a bytecode
object in ways different from those provided by the :mod:`~dis` module
itself. For example::
>>> import dis
>>> for instr in dis.get_instructions(lambda x: x + 1):
... print(instr.opname)
LOAD_FAST
LOAD_CONST
BINARY_ADD
RETURN_VALUE
The various display tools in the :mod:`dis` module have been rewritten to use
these new components.
In addition, a new application-friendly class :class:`~dis.Bytecode` provides
an object-oriented API for inspecting bytecode in both in human-readable form
and for iterating over instructions. The :class:`~dis.Bytecode` constructor
takes the same arguments that :func:`~dis.get_instruction` does (plus an
optional *current_offset*), and the resulting object can be iterated to produce
:class:`~dis.Instruction` objects. But it also has a :mod:`~dis.Bytecode.dis`
method, equivalent to calling :mod:`~dis.dis` on the constructor argument, but
returned as a multi-line string::
>>> bytecode = dis.Bytecode(lambda x: x +1, current_offset=3)
>>> for instr in bytecode:
... print('{} ({})'.format(instr.opname, instr.opcode))
LOAD_FAST (124)
LOAD_CONST (100)
BINARY_ADD (23)
RETURN_VALUE (83)
>>> bytecode.dis().splitlines() # doctest: +NORMALIZE_WHITESPACE
[' 1 0 LOAD_FAST 0 (x)',
' --> 3 LOAD_CONST 1 (1)',
' 6 BINARY_ADD',
' 7 RETURN_VALUE']
:class:`~dis.Bytecode` also has a class method,
:meth:`~dis.Bytecode.from_traceback`, that provides the ability to manipulate a
traceback (that is, ``print(Bytecode.from_traceback(tb).dis())`` is equivalent
to ``distb(tb)``).
(Contributed by Nick Coghlan, Ryan Kelly and Thomas Kluyver in :issue:`11816`
and Claudiu Popa in :issue:`17916`)
...
...
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