bilocate 🪞
Transparent shadow testing for legacy refactors.
Refactoring critical, legacy "spaghetti" code is terrifying. Standard shadow testing requires standing up API gateways, duplicating traffic via Kafka, or importing heavy JSON-diffing engines just to run V2 alongside V1. bilocate solves this at the Python function boundary.
You write your new logic, wrap the old function, and let the runtime natively background and compare the execution.
uv add bilocate
The Difference
| Concept | Standard Shadow Testing | bilocate |
|---|---|---|
| Infrastructure | API Gateways, message duplication queues | None. Pure Python decorators. |
| Diffing Engine | Complex JSON serialization / DeepDiff |
Native __eq__ evaluation. |
| Latency Impact | Network hop duplication | Zero. Async naturally backgrounds. |
| Telemetry & Alerts | Custom SDKs (Datadog/Sentry) | Standard library warnings module. |
Usage
You need exactly one primitive: @mimic.
import bilocate
import warnings
# Your shiny, untested V2 logic
def clean_v2_logic(payload):
return new_pydantic_math(payload)
# 1. Wrap the legacy function.
# The system transparently routes the inputs to V2 in the background.
@bilocate.mimic(clean_v2_logic)
def spaghetti_v1_logic(payload):
return legacy_dict_math(payload)
# 2. Call the function normally.
# The user gets the V1 response instantly.
result = spaghetti_v1_logic({"user_id": 123})
# CHECKPOINT:
# If clean_v2_logic returns a different value, or if V2 crashes while V1 succeeds,
# bilocate emits a native RuntimeWarning. The user's execution is completely unaffected.
Core Mechanics
- Native Telemetry:
bilocaterequires absolutely zero configuration. It doesn't ask for a logger or a statsd client. When a mismatch occurs, it emits a standardRuntimeWarning. You can route this to Sentry, Datadog, or your console natively using Python's built-inlogging.captureWarnings(True). - Flawless Error Diffing:
bilocatetreats exceptions as values. If V1 returnsNonebut V2 raises aKeyError,bilocatecleanly intercepts the crash, compares the terminal states, and reports the discrepancy without blowing up the user's stack. - Native Async Backgrounding: If your functions are
async,bilocateautomatically wraps V2 in a fire-and-forgetasyncio.create_task(). V1 returns instantly, and V2 processes seamlessly in the background event loop with zero added latency. - Zero-Dependency Comparisons: No heavy JSON serializers or deep-diffing libraries.
bilocatedelegates diffing purely to Python's native__eq__contract. If you need to compare a legacydictto a V2 object, just define__eq__on your object.
Release files for bilocate 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| bilocate-0.1.0.tar.gz | 2.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| bilocate-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 6.6 kB
Release files / bilocate-0.1.0.tar.gz
| Download URL | bilocate-0.1.0.tar.gz |
|---|---|
| Size | 2.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a798faa777f0f4d59e8cd55ca8f2741eb8b5cdf36c68ecb890c38fa2405cd6a8
|
|
BLAKE2b-256 checksum How to use checksums |
012b8de94bc952a72a09fc9f6632ca0418b815950c348c8bc9e058686270c09b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.3 {"installer":{"name":"uv","version":"0.11.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"CachyOS Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / bilocate-0.1.0-py3-none-any.whl
| Download URL | bilocate-0.1.0-py3-none-any.whl |
|---|---|
| Size | 3.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d384f935b4ec3aa77c54c2b41e08638efb01b1b85f38742a4638cce83387a1bb
|
|
BLAKE2b-256 checksum How to use checksums |
fdb86c7bfa1a37d6c61a9ad51691d374443234efcb04dc60bea2db52784acbad
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.3 {"installer":{"name":"uv","version":"0.11.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"CachyOS Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|