Atrace
Automatically prints a trace table of simple programs
This module is intended for beginner programmers.
The trace table of examples/small.py is:
╭──────┬───┬───┬──────────────┬──────────────┬─────────────────┬─────────╮
│ line │ x │ y │ greet │ (greet) name │ (greet) message │ output │
├──────┼───┼───┼──────────────┼──────────────┼─────────────────┼─────────┤
│ 3 │ 1 │ 3 │ │ │ │ │
│ 6 │ 2 │ │ │ │ │ │
│ 6 │ 3 │ │ │ │ │ │
│ 8 │ │ │ │ │ │ x: 3 │
│ 11 │ │ │ greet("Bob") │ "Bob" │ │ │
│ 12 │ │ │ │ │ │ "Hi Bob!" │ │
│ 13 │ │ │ └─ "Hi Bob!" │ │ │ │
│ 16 │ │ │ │ │ │ Hi Bob! │
╰──────┴───┴───┴──────────────┴──────────────┴─────────────────┴─────────╯
Installing the package
The package is available on pypi.
Install the latest version with uv, pip, the Thonny package manager, etc.
Generating a trace for code under development
Just import the module at the top of your file, like in examples/small.py
import atrace
x, y = 1, 3
...
Every time you run the program the trace table will be printed when the program exits.
The trace is printed even if the program is interrupted or an uncaught exception is raised.
Programs that use input to interact with the user work, the trace is only printed
at the end of the execution.
Running as a tool
You can display the trace and other visualizations for existing programs (no
need to import atrace in the program).
Note: If you are using uv replace the python3 at the beginning with uv run
To display the trace:
python3 -m atrace examples/fizzbuzz.py
To save the trace to an svg file:
python3 -m atrace examples/fizzbuzz.py --svg local/fizzbuzz.svg
To display the trace as typst markup:
python3 -m atrace.typst examples/fizzbuzz.py
To display a line-by-line animation of the trace:
python3 -m atrace.animated examples/fibonacci.py
To display a histogram of how many times each line in a program is executed: (svg output works the same as for the trace)
python3 -m atrace.histogram examples/nested_loops.py
To display a line-by-line animation of the histogram:
python3 -m atrace.animated_histogram examples/fizzbuzz.py
To display the program with line numbers and syntax highlighting: (svg output also works here)
python3 -m atrace.code examples/fizzbuzz.py
Compatibility
Requires python version 3.10 or higher.
Tested with:
- cpython
- pypy
- Thonny (with the cpython backend)
Does not work well with
- Multithreaded programs
- Multi-module programs
- Debuggers
- Classes
- Context managers
Metadata
Release files for atrace 1.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| atrace-1.1.2.tar.gz | 56.8 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| atrace-1.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 78.7 kB
Release files / atrace-1.1.2.tar.gz
| Download URL | atrace-1.1.2.tar.gz |
|---|---|
| Size | 56.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
513046cf97cc13dd101b0e95c140a47ea2f60a09b1e331f5767b6c0053eb396a
|
|
BLAKE2b-256 checksum How to use checksums |
1bc864b0832c3a4b31019f7771cd2037edc39da118d296aeffaaad94568e63c8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.11.1 {"installer":{"name":"uv","version":"0.11.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / atrace-1.1.2-py3-none-any.whl
| Download URL | atrace-1.1.2-py3-none-any.whl |
|---|---|
| Size | 22.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fb936dc1de326858e1f323536bb820f294cf6a761213ebba893252d4f2e391e5
|
|
BLAKE2b-256 checksum How to use checksums |
e0c11f0b4445740b3fb8c93d1c6358d85edaa566dac072b38d636c462b3be038
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.11.1 {"installer":{"name":"uv","version":"0.11.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for atrace 1.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.