Package Exports
- jupyterlab-python-bytecode
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (jupyterlab-python-bytecode) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
jupyterlab-python-bytecode
JupyterLab extension to inspect Python Bytecode.

Prerequisites
- JupyterLab 0.35
ipykernel
To install JupyterLab:
conda install -c conda-forge jupyterlabInstallation
jupyter labextension install jupyterlab-python-bytecodeContributing
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_VALUEComparing 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:
