• Stars
    star
    59
  • Rank 509,601 (Top 11 %)
  • Language
    TypeScript
  • License
    BSD 3-Clause "New...
  • Created about 6 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

JupyterLab extension to explore CPython Bytecode

jupyterlab-python-bytecode

Github Actions Status Binder npm code style: prettier

JupyterLab extension to inspect Python Bytecode.

screencast

Try it online

Try the extension in your browser with Binder:

Binder

Prerequisites

  • JupyterLab 1.0+
  • ipykernel or xeus-python

To install JupyterLab:

conda install -c conda-forge jupyterlab

Installation

jupyter labextension install jupyterlab-python-bytecode

Features

  • Live Bytecode preview
  • Choose the kernel for a file (if not already started). This allows comparing the bytecode output for different versions of Python.
  • Check the Avanced Settings Editor to tweak some of the settings

Contributing

See CONTRIBUTING.md to know how to contribute and setup a development environment.

How it works

Disassembling the Python code is done by connecting to a kernel, and sending the following code for evaluation from the lab extension:

import dis
dis.dis(code_to_evaluate)

As mentioned in the documentation, there is not guarantee on the stability of the bytecode across Python versions:

Bytecode is an implementation detail of the CPython interpreter. No guarantees are made that bytecode will not be added, removed, or changed between versions of Python. Use of this module should not be considered to work across Python VMs or Python releases.

Example

For example, if the Python file contains the following lines:

import math

print(math.pi)

The following code will be sent to the kernel for evaluation:

import dis
dis.dis("""
import math

print(math.pi)
""")

Which will return (example for CPython 3.6.6):

  1           0 LOAD_CONST               0 (0)
              2 LOAD_CONST               1 (None)
              4 IMPORT_NAME              0 (math)
              6 STORE_NAME               0 (math)

  3           8 LOAD_NAME                1 (print)
             10 LOAD_NAME                0 (math)
             12 LOAD_ATTR                2 (pi)
             14 CALL_FUNCTION            1
             16 POP_TOP
             18 LOAD_CONST               1 (None)
             20 RETURN_VALUE

Comparing versions of CPython

If you have several versions of Python installed on your machine (let's say in different conda environments), you can use the extension to check how the bytecode might differ.

The following example illustrates the introduction of the new CALL_METHOD opcode introduced in CPython 3.7:

python_comparison

Comparing for and while loops

Original example from Disassembling Python Bytecode, by Peter Goldsborough

for_while

More Repositories

1

jupyterlab-system-monitor

JupyterLab extension to display system metrics
TypeScript
284
star
2

ipylab

Control JupyterLab from Python Notebooks with Jupyter Widgets ๐Ÿงช โ˜ข๏ธ ๐Ÿ
TypeScript
144
star
3

trello-full-backup

Python script to backup everything from Trello: boards, lists, cards and attachments
Python
118
star
4

p5-notebook

A Jupyter Notebook environment for p5.js kernels running in the browser, powered by JupyterLite ๐Ÿ’ก
CSS
104
star
5

jupyterlab-python-file

JupyterLab extension to create Python files
Python
53
star
6

replite

An embeddable REPL powered by JupyterLite
Shell
48
star
7

voila-gpx-viewer

GPX Viewer web app built with Jupyter, ipywidgets, ipyleaflet, bqplot and voila
Jupyter Notebook
43
star
8

p5-jupyter-notebook

[UNMAINTAINED] p5.js in the Classic Jupyter Notebook with Jupyter Widgets
Jupyter Notebook
40
star
9

ipyp5

p5.js Jupyter Widget
Python
33
star
10

jammer

Minimalist game server for your game jam
JavaScript
24
star
11

a-tour-of-jupyterlab-extensions

A Tour of JupyterLab Extensions - PyConDE & PyData Berlin 2019
Jupyter Notebook
21
star
12

jupyterlab-heroku

JupyterLab extension to deploy applications to Heroku
TypeScript
20
star
13

jupyterlab-wasm-example

JupyterLab Extension written in Rust and compiled to WebAssembly
Rust
16
star
14

music-globe

Visualize artists events locations on a globe
JavaScript
15
star
15

ipyresuse

Jupyter Widget to display resources used by the kernels
Python
13
star
16

jupyterlab-theme-toggle

JupyterLab extension to toggle the theme in the Top Bar area
TypeScript
11
star
17

pixijs-jupyter

[UNMAINTAINED] Examples of Jupyter Widgets built with Pixi.js
Python
8
star
18

lit

A custom JupyterLite deployment ๐Ÿ”ฅ
Jupyter Notebook
7
star
19

TooManyItems

Entry for the Ludum Dare 26 game jam - April 2013 - "Minimalism"
JavaScript
5
star
20

jupyterlite-labextension-example

Example JupyterLab Extension workflow with JupyterLite
Python
4
star
21

twin-fusion

[Game Jam] Web based social party multiplayer game
JavaScript
3
star
22

pandas-repl

A JupyterLite deployment to easily try pandas in a web browser
3
star
23

pydata-global-2021

Jupyter Notebook
3
star
24

chinese-checkers

Chinese Checkers game in Prolog using min-max algorithm
3
star
25

euroscipy-2022-jupyterlite-emscripten-forge

EuroScipy 2022 - Interactive Data Science in the browser with JupyterLite and Emscripten Forge ๐Ÿ’ก ๐Ÿ
Jupyter Notebook
3
star
26

jupyterlab-codeium

JupyterLab extension to get AI code completions with Codeium
TypeScript
3
star
27

pyconde-jupyterlite-tutorial

Jupyter Notebook
2
star
28

xtl-wasm

A subset of the xtl library compiled to WebAssembly
TypeScript
2
star
29

remote-python-pizza-2020

Control JupyterLab from Python Notebooks - ๐Ÿ• Remote Python Pizza 2020 ๐Ÿ•
Jupyter Notebook
2
star
30

10-minutes-10-jlab-extensions

Lightning Talk at PyData Berlin December Meetup - 2018-12-19
Jupyter Notebook
2
star
31

pyconde-pydata-berlin-2022

Jupyter โค๏ธ WebAssembly โค๏ธ Python Talk at PyCon DE & PyData Berlin 2022 ๐Ÿ
Jupyter Notebook
2
star
32

pyconde-pydata-berlin-2023-jupyterlite-tutorial

Create interactive Jupyter websites with JupyterLite tutorial at Python at PyCon DE & PyData Berlin 2023
HTML
2
star
33

ipyclipboard

A simple Jupyter Widget to read and write text from the clipboard.
Jupyter Notebook
2
star
34

jupyterlab-iframe-bridge-example

An example bridge extension to demo passing messages between a host page and JupyterLab running in an IFrame.
JavaScript
2
star
35

jupyterlab-yjs-example

Example of using Yjs in JupyterLab for collaborative editing
Python
1
star
36

pydata-heidelberg-workshop

Starter Pack for the Voilร  workshop at PyData Heidelberg - 2020-01-09
Jupyter Notebook
1
star
37

jupyter-open-studio-day-nyc-2024

Jupyter Open Studio Day, NYC, April 29th 2024
Jupyter Notebook
1
star
38

jackD

Arabic Game Jam 2013 - Together We Grow
GLSL
1
star
39

data-playground

Experiments using public APIs and data
Jupyter Notebook
1
star
40

scratchpad

Jupyter Notebook
1
star
41

jupytercon-2023-jupyterlite

Create interactive Jupyter websites with JupyterLite - JupyterCon 2023 ๐Ÿ’ก
Jupyter Notebook
1
star
42

ngj16

Nordic Game Jam 2016 - L3-AK
Python
1
star
43

voila-gallery-binderhub

[DEMO] Voila Gallery powered by BinderHub, Jekyll and GitHub pages
HTML
1
star
44

python-meetup-grenoble-2023

Crรฉer des sites web Jupyter interactifs avec JupyterLite
Jupyter Notebook
1
star
45

pyconde-pydata-berlin-2023-notebook-7

The Future of the Jupyter Notebook interface at PyCon DE & PyData Berlin 2023 ๐Ÿ
HTML
1
star
46

jtpio.github.io

Personal website and blog
Jupyter Notebook
1
star
47

langton-ant-haskell

Langton's Ant in Haskell
Haskell
1
star
48

python-pizza-berlin

๐Ÿ• ๐Ÿ 10 Minutes Talk at Python Pizza Berlin 2019 ๐Ÿ ๐Ÿ• - 2019-02-23 at @wooga
Jupyter Notebook
1
star
49

tdg

A Tower Defense game concept, made with node and pixi.js at Copenhagen Node.js Hackathon
JavaScript
1
star
50

anywidget-lite

Prototype your Jupyter Widget in the browser with anywidget and JupyterLite ๐Ÿ’ก
Jupyter Notebook
1
star
51

jupyterlab-rspack

[WIP] Build JupyterLab extensions with Rspack (Rust powered Webpack)
TypeScript
1
star