Skip to main content

pytrace-inject: Runtime AOP injection for Python.

A lightweight framework that lets you intercept and modify local variables at any execution point of a target function, using sys.settrace.

Quick Start

import random
from pytrace_inject import At, inject, start_trace, end_trace

@inject(At(random.randrange).atcall())
def modify(start, end):
    start, end = 42, 43
    return {'start': start, 'end': end}

start_trace()
print(random.randrange(100, 999))  # Output: 42
end_trace()

Key Concepts

  • At — Where to inject (call time / return time / specific line / custom condition).
  • Tracer — The active injection, can be .remove()'d at any time.
  • Callback — Your function that receives current local variables and returns a dict of replacements (or None).

License

MIT — see LICENSE file.

Release files for pytrace-inject 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytrace-inject 0.2.0
File Size Uploaded
pytrace_inject-0.2.0.tar.gz 4.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pytrace-inject 0.2.0
File Interpreter ABI Platform
pytrace_inject-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 11.0 kB

Release files / pytrace_inject-0.2.0.tar.gz

Download URL pytrace_inject-0.2.0.tar.gz
Size 4.8 kB
Tags Source
SHA-256 checksum
How to use checksums
55e46f4d67f7093645822e7d529bedc76a8c5b30fa89e714bf236a10ad43615e
BLAKE2b-256 checksum
How to use checksums
74baff2b4bf240ab282272730861a0e4a3707dfa1f6bd6d9f3d9660e039a3278
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 21, 2026.

Transparency log

Release files / pytrace_inject-0.2.0-py3-none-any.whl

Download URL pytrace_inject-0.2.0-py3-none-any.whl
Size 6.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4a53946411220d0e226169a61c85ab036a12e6165a3c37999ca9f6717f516e8d
BLAKE2b-256 checksum
How to use checksums
0e85279cc1170bc8617c56b71e02a2159bef672e9614726ae14ebeb2b213d8e0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 21, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.3

2 release files

0.1.2

2 release 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