@@ -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 `::
@@ -71,8 +73,8 @@ The bytecode analysis API allows pieces of Python code to be wrapped in a
7173:class: `Bytecode ` object that provides easy access to details of the compiled
7274code.
7375
74- .. class :: Bytecode(x, *, first_line=None, current_offset=None, show_caches=False)
75-
76+ .. class :: Bytecode(x, *, first_line=None, current_offset=None,\
77+ show_caches=False, adaptive=False)
7678
7779 Analyse the bytecode corresponding to a function, generator, asynchronous
7880 generator, coroutine, method, string of source code, or a code object (as
9193 disassembled code. Setting this means :meth: `.dis ` will display a "current
9294 instruction" marker against the specified opcode.
9395
96+ If *show_caches * is ``True ``, :meth: `.dis ` will display inline cache
97+ entries used by the interpreter to specialize the bytecode.
98+
99+ If *adaptive * is ``True ``, :meth: `.dis ` will display specialized bytecode
100+ that may be different from the original bytecode.
101+
94102 .. classmethod :: from_traceback(tb, *, show_caches=False)
95103
96104 Construct a :class: `Bytecode ` instance from the given traceback, setting
@@ -118,7 +126,7 @@ code.
118126 This can now handle coroutine and asynchronous generator objects.
119127
120128 .. versionchanged :: 3.11
121- Added the `` show_caches `` parameter .
129+ Added the * show_caches * and * adaptive * parameters .
122130
123131Example:
124132
@@ -174,7 +182,7 @@ operation is being performed, so the intermediate analysis object isn't useful:
174182 Added *file * parameter.
175183
176184
177- .. function :: dis(x=None, *, file=None, depth=None, show_caches=False)
185+ .. function :: dis(x=None, *, file=None, depth=None, show_caches=False, adaptive=False )
178186
179187 Disassemble the *x * object. *x * can denote either a module, a class, a
180188 method, a function, a generator, an asynchronous generator, a coroutine,
@@ -195,6 +203,12 @@ operation is being performed, so the intermediate analysis object isn't useful:
195203 The maximal depth of recursion is limited by *depth * unless it is ``None ``.
196204 ``depth=0 `` means no recursion.
197205
206+ If *show_caches * is ``True ``, this function will display inline cache
207+ entries used by the interpreter to specialize the bytecode.
208+
209+ If *adaptive * is ``True ``, this function will display specialized bytecode
210+ that may be different from the original bytecode.
211+
198212 .. versionchanged :: 3.4
199213 Added *file * parameter.
200214
@@ -205,10 +219,10 @@ operation is being performed, so the intermediate analysis object isn't useful:
205219 This can now handle coroutine and asynchronous generator objects.
206220
207221 .. versionchanged :: 3.11
208- Added the `` show_caches `` parameter .
222+ Added the * show_caches * and * adaptive * parameters .
209223
210224
211- .. function :: distb(tb=None, *, file=None, show_caches=False)
225+ .. function :: distb(tb=None, *, file=None, show_caches=False, adaptive=False )
212226
213227 Disassemble the top-of-stack function of a traceback, using the last
214228 traceback if none was passed. The instruction causing the exception is
@@ -221,11 +235,11 @@ operation is being performed, so the intermediate analysis object isn't useful:
221235 Added *file * parameter.
222236
223237 .. versionchanged :: 3.11
224- Added the `` show_caches `` parameter .
238+ Added the * show_caches * and * adaptive * parameters .
225239
226240
227- .. function :: disassemble(code, lasti=-1, *, file=None, show_caches=False)
228- disco(code, lasti=-1, *, file=None, show_caches=False)
241+ .. function :: disassemble(code, lasti=-1, *, file=None, show_caches=False, adaptive=False )
242+ disco(code, lasti=-1, *, file=None, show_caches=False, adaptive=False )
229243
230244 Disassemble a code object, indicating the last instruction if *lasti * was
231245 provided. The output is divided in the following columns:
@@ -248,10 +262,10 @@ operation is being performed, so the intermediate analysis object isn't useful:
248262 Added *file * parameter.
249263
250264 .. versionchanged :: 3.11
251- Added the `` show_caches `` parameter .
265+ Added the * show_caches * and * adaptive * parameters .
252266
253267
254- .. function :: get_instructions(x, *, first_line=None, show_caches=False)
268+ .. function :: get_instructions(x, *, first_line=None, show_caches=False, adaptive=False )
255269
256270 Return an iterator over the instructions in the supplied function, method,
257271 source code string or code object.
@@ -264,10 +278,12 @@ operation is being performed, so the intermediate analysis object isn't useful:
264278 source line information (if any) is taken directly from the disassembled code
265279 object.
266280
281+ The *show_caches * and *adaptive * parameters work as they do in :func: `dis `.
282+
267283 .. versionadded :: 3.4
268284
269285 .. versionchanged :: 3.11
270- Added the `` show_caches `` parameter .
286+ Added the * show_caches * and * adaptive * parameters .
271287
272288
273289.. function :: findlinestarts(code)
0 commit comments