Skip to content

IDLE: add a disassembly browser #152966

Description

@serhiy-storchaka

Feature or enhancement

Completing the browser series alongside the token (#152941) and AST (#152942) browsers, seeing the disassembled bytecode helps in learning how CPython compiles code and in understanding what the interpreter actually executes.

I propose a Disassembly Browser added as an extension on the Tools menu (Shell and editor). It shows the disassembled bytecode of the current window. Each code object is a collapsible row of its instructions; nested code objects (functions, classes, comprehensions, ...) are shown as further rows.

Interaction:

  • Selecting an instruction highlights the corresponding source in the editor and, while the browser has focus, moves the cursor there.
  • The browser follows the editor: selecting text or moving the cursor selects the matching instructions.
  • Double-clicking a row (or pressing Escape) hides the browser, revealing the editor at that instruction.
  • Scope is the editor selection if there is one, else the Shell's current input, else the whole window.

While the debugger is stopped, the browser follows it instead of the editor: it shows the code object that is actually executing and marks the instruction the frame is stopped at.

It shares the window skeleton and editor-sync mechanism with the token and AST browsers.

A PR will follow.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytopic-IDLEtype-featureA feature request or enhancement

    Fields

    No fields configured for issues without a type.

    Projects

    Status
    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions