Skip to main content

Panopticon

Panopticon is a debugger-powered tracer for Python code to quickly visualize and explore code execution. Traces generated are Catapult compatible — available at `chrome://tracing` if you're using Chrome.

Sample trace with async functions

Motivation & Internals

Python already has an excellent tracer module, but I wanted a more convenient way to observe what's actually going on across threads and coroutines. I'd used Catapult in a past life while working on Android, and that seemed like an excellent way to quickly get detailed visualizations of code execution that I could parse.

The current version is fairly simple, and relies on Python's setprofile to observe function transitions. Coroutines and other "continuable" frames are identified by their location in memory, and "closed" when they end with a RETURN_VALUE opcode.

Usage

Run a command directly

python3 -m panopticon -c "print('hello')" -o print_hello.trace

Run a file

python3 -m panopticon -o file.trace file.py 

In code

with panopticon.tracer.AsyncTracer() as at:
    print("Hello")

with open("print_hello.trace", "w") as outfile:
    outfile.write(str(at))

Asynchronous Functions

Python supports suspending and continuing execution of a frame through generators, coroutines and asynchronous generators. Panopticon creates "flow" events to connect a single frame executing through time, making it easier to visualize what's actually happening.

You can enable/disable connections for different types of functions by choosing to enable/disable flow events in Catpult (top-right).

Changelog

0.0.1

  • Initial version of Panopticon
  • CLI supports running commands and files for tracing

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

panopticon-0.0.1.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

panopticon-0.0.1-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file panopticon-0.0.1.tar.gz.

File metadata

  • Download URL: panopticon-0.0.1.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.3

File hashes

Hashes for panopticon-0.0.1.tar.gz
Algorithm Hash digest
SHA256 ec301286cae14a7800c7f5b2cf894b84151558c6b8e5b269f70739235fea6d98
MD5 e6a3a35a6ddcf839dcfbaf6aaf7d8946
BLAKE2b-256 d8a235a7ab157b340fe363b1dca1555357943c2f02506bf102127bf5164f15b2

See more details on using hashes here.

File details

Details for the file panopticon-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: panopticon-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 6.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.3

File hashes

Hashes for panopticon-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 833d8adda9caf14834023e603748b690aabe081501348c44bfa8ef321ed43956
MD5 c2fb88cd67c4542811d033c124ed7956
BLAKE2b-256 86de0d39a7d663c41530d20ee74236b925daff82c9de3b917893836d57c66be9

See more details on using hashes here.

Release history Release notifications | RSS feed

0.0.4

2 files

0.0.3

2 files

0.0.2

2 files

This release

0.0.1 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page