@@ -38,7 +38,9 @@ interpreter.
3838 Some instructions are accompanied by one or more inline cache entries,
3939 which take the form of :opcode: `CACHE ` instructions. These instructions
4040 are hidden by default, but can be shown by passing ``show_caches=True `` to
41- any :mod: `dis ` utility.
41+ any :mod: `dis ` utility. Furthermore, the interpreter now adapts the
42+ bytecode to specialize it for different runtime conditions. The
43+ adaptive bytecode can be shown by passing ``adaptive=True ``.
4244
4345
4446Example: Given the function :func: `myfunc `::
@@ -70,8 +72,8 @@ The bytecode analysis API allows pieces of Python code to be wrapped in a
7072:class: `Bytecode ` object that provides easy access to details of the compiled
7173code.
7274
73- .. class :: Bytecode(x, *, first_line=None, current_offset=None, show_caches=False)
74-
75+ .. class :: Bytecode(x, *, first_line=None, current_offset=None,\
76+ show_caches=False, adaptive=False)
7577
7678 Analyse the bytecode corresponding to a function, generator, asynchronous
7779 generator, coroutine, method, string of source code, or a code object (as
9092 disassembled code. Setting this means :meth: `.dis ` will display a "current
9193 instruction" marker against the specified opcode.
9294
95+ If *show_caches * is ``True ``, :meth: `.dis ` will display inline cache
96+ entries used by the interpreter to specialize the bytecode.
97+
98+ If *adaptive * is ``True ``, :meth: `.dis ` will display specialized bytecode
99+ that may be different from the original bytecode.
100+
93101 .. classmethod :: from_traceback(tb, *, show_caches=False)
94102
95103 Construct a :class: `Bytecode ` instance from the given traceback, setting
@@ -117,7 +125,7 @@ code.
117125 This can now handle coroutine and asynchronous generator objects.
118126
119127 .. versionchanged :: 3.11
120- Added the `` show_caches `` parameter .
128+ Added the * show_caches * and * adaptive * parameters .
121129
122130Example:
123131
@@ -172,7 +180,7 @@ operation is being performed, so the intermediate analysis object isn't useful:
172180 Added *file * parameter.
173181
174182
175- .. function :: dis(x=None, *, file=None, depth=None, show_caches=False)
183+ .. function :: dis(x=None, *, file=None, depth=None, show_caches=False, adaptive=False )
176184
177185 Disassemble the *x * object. *x * can denote either a module, a class, a
178186 method, a function, a generator, an asynchronous generator, a coroutine,
@@ -193,6 +201,12 @@ operation is being performed, so the intermediate analysis object isn't useful:
193201 The maximal depth of recursion is limited by *depth * unless it is ``None ``.
194202 ``depth=0 `` means no recursion.
195203
204+ If *show_caches * is ``True ``, this function will display inline cache
205+ entries used by the interpreter to specialize the bytecode.
206+
207+ If *adaptive * is ``True ``, this function will display specialized bytecode
208+ that may be different from the original bytecode.
209+
196210 .. versionchanged :: 3.4
197211 Added *file * parameter.
198212
@@ -203,10 +217,10 @@ operation is being performed, so the intermediate analysis object isn't useful:
203217 This can now handle coroutine and asynchronous generator objects.
204218
205219 .. versionchanged :: 3.11
206- Added the `` show_caches `` parameter .
220+ Added the * show_caches * and * adaptive * parameters .
207221
208222
209- .. function :: distb(tb=None, *, file=None, show_caches=False)
223+ .. function :: distb(tb=None, *, file=None, show_caches=False, adaptive=False )
210224
211225 Disassemble the top-of-stack function of a traceback, using the last
212226 traceback if none was passed. The instruction causing the exception is
@@ -219,11 +233,11 @@ operation is being performed, so the intermediate analysis object isn't useful:
219233 Added *file * parameter.
220234
221235 .. versionchanged :: 3.11
222- Added the `` show_caches `` parameter .
236+ Added the * show_caches * and * adaptive * parameters .
223237
224238
225- .. function :: disassemble(code, lasti=-1, *, file=None, show_caches=False)
226- disco(code, lasti=-1, *, file=None, show_caches=False)
239+ .. function :: disassemble(code, lasti=-1, *, file=None, show_caches=False, adaptive=False )
240+ disco(code, lasti=-1, *, file=None, show_caches=False, adaptive=False )
227241
228242 Disassemble a code object, indicating the last instruction if *lasti * was
229243 provided. The output is divided in the following columns:
@@ -246,10 +260,10 @@ operation is being performed, so the intermediate analysis object isn't useful:
246260 Added *file * parameter.
247261
248262 .. versionchanged :: 3.11
249- Added the `` show_caches `` parameter .
263+ Added the * show_caches * and * adaptive * parameters .
250264
251265
252- .. function :: get_instructions(x, *, first_line=None, show_caches=False)
266+ .. function :: get_instructions(x, *, first_line=None, show_caches=False, adaptive=False )
253267
254268 Return an iterator over the instructions in the supplied function, method,
255269 source code string or code object.
@@ -262,10 +276,12 @@ operation is being performed, so the intermediate analysis object isn't useful:
262276 source line information (if any) is taken directly from the disassembled code
263277 object.
264278
279+ The *show_caches * and *adaptive * parameters work as they do in :func: `dis `.
280+
265281 .. versionadded :: 3.4
266282
267283 .. versionchanged :: 3.11
268- Added the `` show_caches `` parameter .
284+ Added the * show_caches * and * adaptive * parameters .
269285
270286
271287.. function :: findlinestarts(code)
0 commit comments