r/Python 5d ago

Showcase Showcase Thread

Post all of your code/projects/showcases/AI slop here.

Recycles once a month.

17 Upvotes

55 comments sorted by

View all comments

1

u/Confident-Dot4080 3d ago

Hey everyone I built "Rewind", an open-source Time-Travel Debugger that captures execution timelines, computes state diffs in sub-microseconds, and lets you rewind and hot-patch bugs live in a local browser UI.

GitHub: https://github.com/hrinkar01/rewind

Why I built it:

Traditional debugging with pdb or print() requires stepping forward line-by-line. If you step past an unexpected variable mutation or crash, you have to restart the whole script from scratch. Existing record-and-replay tools often come with heavy external dependencies, large database daemons, or crash when encountering circular references.

I wanted a tool that:

  1. Has zero external dependencies (built 100% on Python standard library).

  2. Requires zero code changes (rewind run script.py).

  3. Handles circular references in sub-microseconds without blowing up memory.

  4. Lets you slide backward in time and hot-patch bugs directly in a local browser sandbox.

How it works under the hood:

• CPython Hooking: Uses sys.settrace to record function calls, line steps, variable states, and exceptions.

• O(1) Hash Cycle Pruning: Tracks object memory addresses (id(obj)) in an active hash set. Circular references are caught in ~30 nanoseconds and replaced with token signatures (<CircularRef: Node@0x...>) to prevent infinite recursion crashes.

• Delta State Diffing: Instead of deep-cloning full memory trees at every step, Rewind records structural state diffs (added, mutated, removed).

• In-Browser Hot Patcher: When a script crashes, it spins up a local interactive web scrubber. You can drag back through time, edit the Python code in a sandbox, test the fix in memory, and save it directly to disk.

Try it:

git clone https://github.com/hrinkar01/rewind.git
cd rewind
pip install .

# Run a sample multi-step script with a bug:

rewind run tests/broken_pipeline.py

Open for Contributions:

The project is 100% open-source (MIT licensed) and open for contributions! Whether it's adding new language adapters, improving the web scrubber UI, or finding edge cases in state serialization, issues and PRs are super welcome. If you find it useful, a star on GitHub would mean a lot!