Skip to main content

High-performance Python exception snapshot library

Project description

Tintype

Tintype is a high-performance Python library for capturing exception snapshots. It serializes call stacks, exception chains, local variables, and the full reachable object graph into a compact binary format (.pytb) that can be inspected offline.

Built as a C++/Python hybrid using pybind11, tintype is designed for minimal overhead in production environments.

Features

  • Full object graph capture — serializes local variables and their entire reachable object tree, not just repr strings
  • Exception chain support — follows __cause__ and __context__ chains automatically
  • Multi-thread snapshots — captures all Python thread stacks atomically via sys._current_frames()
  • Periodic sampling — built-in C++ timer thread for profiling workloads
  • Exception hook — one-liner to capture snapshots on unhandled exceptions
  • Compact binary format — zstd-compressed with cross-snapshot object deduplication
  • Source file embedding — referenced source files are stored in the snapshot for offline viewing
  • Synthetic tracebacks — reconstruct Python traceback objects for post-mortem debugging

Installation

pip install tintype

Requirements: Python ≥ 3.10, a C++17 compiler, and zstd.

Quick Start

Capture a snapshot

import tintype

tintype.initialize()

# Capture the current call stack
tintype.take_snapshot()

# Capture an exception with its full chain
try:
    1 / 0
except Exception as e:
    tintype.take_snapshot(e)

# Write to disk
tintype.finalize("/tmp/my_snapshot.pytb", metadata={"app": "my_app"})

Read a snapshot file

import tintype

reader = tintype.SnapshotReader("/tmp/my_snapshot.pytb")

for snap in reader.get_all_snapshots():
    print(f"Timestamp: {snap.timestamp}")
    for st_id, st in snap.stacktraces.items():
        print(f"  Thread {st.thread_name}: {len(st.frames)} frames")
        if st.exception_object:
            print(f"    Exception: {st.exception_object}")
        for frame in st.frames:
            print(f"    {frame.function_name} ({frame.file_path}:{frame.line_number})")
            for name, value in frame.get_locals().items():
                print(f"      {name} = {value!r}")

Capture all threads

import tintype

tintype.initialize()
tintype.snapshot_all_threads(timeout=2.0)
tintype.finalize("/tmp/all_threads.pytb")

Periodic sampling

import tintype

with tintype.sampling(
    interval=0.1,
    mode=tintype.SamplingMode.ALL_THREADS,
    path="/tmp/profile.pytb",
    timeout=2.0,
):
    run_workload()

Exception hook

import tintype

# One-liner: capture a snapshot on any unhandled exception
tintype.install_exception_hook(path="/tmp/crash.pytb")

Or with a custom callback:

import tintype

def on_snapshot(path: str) -> None:
    upload_to_crash_service(path)

tintype.install_exception_hook(callback=on_snapshot)

API Overview

Module Functions

Function Description
initialize(collect_stats, frame_file_path_filters) Initialize the snapshot system. Returns a live SnapshotReader.
take_snapshot(traceback_or_exception, ...) Capture a snapshot of the current stack, a traceback, or an exception chain.
snapshot_all_threads(timeout, max_frames, ...) Capture all Python threads atomically.
finalize(path, metadata, compression_level) Compress and write the snapshot file to disk.
enable_sampling(interval, mode, ...) Start periodic sampling on a C++ timer thread.
disable_sampling() Stop periodic sampling.
sampling(interval, mode, ..., path) Context manager: initialize, sample, and finalize.
install_exception_hook(path, callback, ...) Install sys.excepthook to capture snapshots automatically.
cancel_snapshot() Thread-safe cancellation of the current snapshot.
get_stats() / reset_stats() Performance statistics (when collect_stats=True).

Classes

Class Description
SnapshotReader Reads .pytb files. Supports iteration, random access, and live reading.
Snapshot A single snapshot record with stacktraces and an object map.
Stacktrace A thread's call stack or an exception's traceback with frames.
Frame A stack frame with file path, function name, line number, and local variables.
SerializedObject A deserialized complex object with a custom repr.
SamplingMode Enum: ALL_THREADS or SINGLE_THREAD.

For the complete API reference, see PYTHON_API.md.

File Format

Tintype uses a custom binary format (.pytb) designed for efficient capture and compact storage. See snapshot_lib/FILE_FORMAT.md for the byte-level specification.

License

MIT License. See LICENSE for details.

Project details


Download files

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

Source Distribution

tintype-0.1.1.tar.gz (125.6 kB view details)

Uploaded Source

Built Distributions

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

tintype-0.1.1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (710.0 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

tintype-0.1.1-cp313-cp313-macosx_11_0_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.13macOS 11.0+ x86-64

tintype-0.1.1-cp313-cp313-macosx_11_0_arm64.whl (1.1 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

tintype-0.1.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (710.0 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

tintype-0.1.1-cp312-cp312-macosx_11_0_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.12macOS 11.0+ x86-64

tintype-0.1.1-cp312-cp312-macosx_11_0_arm64.whl (1.1 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

File details

Details for the file tintype-0.1.1.tar.gz.

File metadata

  • Download URL: tintype-0.1.1.tar.gz
  • Upload date:
  • Size: 125.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for tintype-0.1.1.tar.gz
Algorithm Hash digest
SHA256 7b92e8a4debd3e6762d35a5b967c1b740558c52a990b38ccdbbdf7d311c791bf
MD5 96d45690d61892261a8807bba2b84a64
BLAKE2b-256 0ce70a280007f7ec225b70b116ebf98b70526b3512047883318e84639e333cd9

See more details on using hashes here.

Provenance

The following attestation bundles were made for tintype-0.1.1.tar.gz:

Publisher: release.yml on facebookincubator/tintype

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tintype-0.1.1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for tintype-0.1.1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 42de7ba0a6895e11695b4c405b8eefa788d0cf69527f6656e6d85e4fe2eb1b8b
MD5 0f7da36a787307eb37dcd838ff17d4b0
BLAKE2b-256 ceb8f7e55e94fb4515c2a5bb6520e4a2130d7c0b435a11a4a1ed7fcb998efc9e

See more details on using hashes here.

Provenance

The following attestation bundles were made for tintype-0.1.1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: release.yml on facebookincubator/tintype

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tintype-0.1.1-cp313-cp313-macosx_11_0_x86_64.whl.

File metadata

File hashes

Hashes for tintype-0.1.1-cp313-cp313-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 2a71a5d9139b70d77302a19f6a70e707a1e1148ef48355dff395bf50ea611a86
MD5 8614bda1ae713371c1e62571f53f7087
BLAKE2b-256 02a9c6f63e93a909cbbcecddc01b33fdca9848868bd10df51445081326f71055

See more details on using hashes here.

Provenance

The following attestation bundles were made for tintype-0.1.1-cp313-cp313-macosx_11_0_x86_64.whl:

Publisher: release.yml on facebookincubator/tintype

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tintype-0.1.1-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for tintype-0.1.1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e02c528eafb79d402a0c668030533a2ea5e87f60b26f52466338552769b44165
MD5 8d77ff181f2e57d2321c2eb86d2ac44b
BLAKE2b-256 0e98c0318634fbd31de14f5e70ebdf0e88bc233ea6aa540a448cc318759b64a6

See more details on using hashes here.

Provenance

The following attestation bundles were made for tintype-0.1.1-cp313-cp313-macosx_11_0_arm64.whl:

Publisher: release.yml on facebookincubator/tintype

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tintype-0.1.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for tintype-0.1.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 67b7ac394ea14181d406cec2b17de01c9831afeb71b88d6a0e452aa363c9da60
MD5 dc75f5c90d4e14c410d2ae3d3bf67b80
BLAKE2b-256 c74ccce5cd677c840e0abbfbc67c97f869ae07b6d6cbfaf5302d094387a35292

See more details on using hashes here.

Provenance

The following attestation bundles were made for tintype-0.1.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: release.yml on facebookincubator/tintype

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tintype-0.1.1-cp312-cp312-macosx_11_0_x86_64.whl.

File metadata

File hashes

Hashes for tintype-0.1.1-cp312-cp312-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 6dbf7cc3a8cd36e4c6f7cbc7a2991810185b3460b42f594c16884a181537ea73
MD5 1bcdadaf6a7340a74cc609e5847e46d4
BLAKE2b-256 55b755b14af1536b24540756694f1b056221ca4f1ca92324abae7477b3927350

See more details on using hashes here.

Provenance

The following attestation bundles were made for tintype-0.1.1-cp312-cp312-macosx_11_0_x86_64.whl:

Publisher: release.yml on facebookincubator/tintype

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tintype-0.1.1-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for tintype-0.1.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e51002cdd486c84fdd1d16a1bc71fd7ab2f7b0399f74be378cebe2f07f1cddf0
MD5 afafc248b858beb5540153756f4a68e2
BLAKE2b-256 3d29339d43b3e672f3cee5a201236fd591aeabe07f96cfcb750a47d0e170b749

See more details on using hashes here.

Provenance

The following attestation bundles were made for tintype-0.1.1-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: release.yml on facebookincubator/tintype

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page