@@ -24,6 +24,12 @@ interpreter.
24
24
Use 2 bytes for each instruction. Previously the number of bytes varied
25
25
by instruction.
26
26
27
+ .. versionchanged :: 3.11
28
+ Some instructions are accompanied by one or more inline cache entries,
29
+ which take the form of :opcode: `CACHE ` instructions. These instructions
30
+ are hidden by default, but can be shown by passing ``show_caches=True `` to
31
+ any :mod: `dis ` utility.
32
+
27
33
28
34
Example: Given the function :func: `myfunc `::
29
35
@@ -54,7 +60,7 @@ The bytecode analysis API allows pieces of Python code to be wrapped in a
54
60
:class: `Bytecode ` object that provides easy access to details of the compiled
55
61
code.
56
62
57
- .. class :: Bytecode(x, *, first_line=None, current_offset=None)
63
+ .. class :: Bytecode(x, *, first_line=None, current_offset=None, show_caches=False )
58
64
59
65
60
66
Analyse the bytecode corresponding to a function, generator, asynchronous
74
80
disassembled code. Setting this means :meth: `.dis ` will display a "current
75
81
instruction" marker against the specified opcode.
76
82
77
- .. classmethod :: from_traceback(tb)
83
+ .. classmethod :: from_traceback(tb, *, show_caches=False )
78
84
79
85
Construct a :class: `Bytecode ` instance from the given traceback, setting
80
86
*current_offset * to the instruction responsible for the exception.
@@ -100,6 +106,9 @@ code.
100
106
.. versionchanged :: 3.7
101
107
This can now handle coroutine and asynchronous generator objects.
102
108
109
+ .. versionchanged :: 3.11
110
+ Added the ``show_caches `` parameter.
111
+
103
112
Example::
104
113
105
114
>>> bytecode = dis.Bytecode(myfunc)
@@ -153,7 +162,7 @@ operation is being performed, so the intermediate analysis object isn't useful:
153
162
Added *file * parameter.
154
163
155
164
156
- .. function :: dis(x=None, *, file=None, depth=None)
165
+ .. function :: dis(x=None, *, file=None, depth=None, show_caches=False )
157
166
158
167
Disassemble the *x * object. *x * can denote either a module, a class, a
159
168
method, a function, a generator, an asynchronous generator, a coroutine,
@@ -183,8 +192,11 @@ operation is being performed, so the intermediate analysis object isn't useful:
183
192
.. versionchanged :: 3.7
184
193
This can now handle coroutine and asynchronous generator objects.
185
194
195
+ .. versionchanged :: 3.11
196
+ Added the ``show_caches `` parameter.
197
+
186
198
187
- .. function :: distb(tb=None, *, file=None)
199
+ .. function :: distb(tb=None, *, file=None, show_caches=False )
188
200
189
201
Disassemble the top-of-stack function of a traceback, using the last
190
202
traceback if none was passed. The instruction causing the exception is
@@ -196,9 +208,12 @@ operation is being performed, so the intermediate analysis object isn't useful:
196
208
.. versionchanged :: 3.4
197
209
Added *file * parameter.
198
210
211
+ .. versionchanged :: 3.11
212
+ Added the ``show_caches `` parameter.
213
+
199
214
200
- .. function :: disassemble(code, lasti=-1, *, file=None)
201
- disco(code, lasti=-1, *, file=None)
215
+ .. function :: disassemble(code, lasti=-1, *, file=None, show_caches=False )
216
+ disco(code, lasti=-1, *, file=None, show_caches=False )
202
217
203
218
Disassemble a code object, indicating the last instruction if *lasti * was
204
219
provided. The output is divided in the following columns:
@@ -220,8 +235,11 @@ operation is being performed, so the intermediate analysis object isn't useful:
220
235
.. versionchanged :: 3.4
221
236
Added *file * parameter.
222
237
238
+ .. versionchanged :: 3.11
239
+ Added the ``show_caches `` parameter.
240
+
223
241
224
- .. function :: get_instructions(x, *, first_line=None)
242
+ .. function :: get_instructions(x, *, first_line=None, show_caches=False )
225
243
226
244
Return an iterator over the instructions in the supplied function, method,
227
245
source code string or code object.
@@ -236,6 +254,9 @@ operation is being performed, so the intermediate analysis object isn't useful:
236
254
237
255
.. versionadded :: 3.4
238
256
257
+ .. versionchanged :: 3.11
258
+ Added the ``show_caches `` parameter.
259
+
239
260
240
261
.. function :: findlinestarts(code)
241
262
0 commit comments