python / python/cpython

IDLE: add a bytecode browser

Open
#152,966 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

stdlib topic-IDLE type-feature
Dominant language
Python
Stars
77.2k
Forks
35.9k
PR merge metrics
PR metrics pending

Description

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
  • gh-152974

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Review the token and AST browsers, their shared window skeleton and editor-sync mechanism, and linked PR gh-152974 first. Use the issue's interaction and scope rules as the acceptance criteria: bytecode should be browsable by code object, synchronize with the editor or debugger, and hide back to the relevant instruction.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
desktop, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.