laboratory
Sure-footed refactoring achieved through experimenting
Decision gist · record as of 2026-08-14
Yes, if you own critical code paths and want a structured way to validate refactors in production. The zero-dependency design and MIT license make it low-risk to add. However, the aging maintenance status (last release 2019) means you should verify it works with your target Python version and be prepared to maintain a fork if needed. Not suitable for code with side effects.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Code with side effects (database writes, file I/O, state mutations) will execute in both control and candidate branches, causing duplicated writes—unsuitable for such operations.
- Low friction: pure Python wheel with no runtime dependencies.
- However, the package is aging—last release was 2019-05-05 and last commit 2025-12-22, so while not abandoned, it receives infrequent updates.
License · maintenance · safety
MIT (permissive) — MIT license (permissive) means you can use, modify, and distribute this package freely in commercial and private projects with minimal restrictions.
last release 2019-05-05 (2658 days) · last repo commit 2025-12-22 · 1,282 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 174,049 downloads/mo, #10,293 on PyPI
Alternatives
Verify before relying
pip install laboratory
import laboratory
experiment = laboratory.Experiment()
experiment.control(old_func, args=[data])
experiment.candidate(new_func, args=[data])
result = experiment.conduct() # returns old_func's value- Whether the package still works reliably with modern Python versions beyond those listed in classifiers (3.6 was the latest in the original release metadata).
- Current state of the GitHub repository and whether maintenance is truly active despite the aging status flag.
What it is and what it does
Laboratory is a Python framework for running controlled experiments on refactored code in production. You define a control block (your existing, known-good code) and a candidate block (your new implementation), and Laboratory executes both in randomized order, compares their return values, records timing, catches exceptions in the candidate, and publishes results—while always returning the control value to the caller. This lets you gain confidence that a refactor is correct before fully committing to it, even in complex production environments with legacy data and high load.
The package is designed for critical code paths where correctness matters more than speed. You can ramp experiments up gradually by overriding the `enabled` method, customize comparison logic, add context for debugging, and implement your own `publish` method to send metrics and mismatches to monitoring systems. The main caveat is that code with side effects (database writes, state changes) is unsuitable because both branches will execute, potentially causing duplicate writes.
Use it for
- Refactoring authorization or permission-checking logic in production while verifying the new code matches the old behavior.
- Gradually migrating from one database query strategy to another by running both and comparing results before switching fully.
- Testing a rewritten algorithm on real production data and load to catch edge cases that unit tests miss.
- Validating a new authentication method against the existing one without risking user lockouts.
- Ramping up a candidate implementation for only a subset of users or requests to limit blast radius if issues arise.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes, if you own critical code paths and want a structured way to validate refactors in production.
The zero-dependency design and MIT license make it low-risk to add. However, the aging maintenance status (last release 2019) means you should verify it works with your target Python version and be prepared to maintain a fork if needed. Not suitable for code with side effects.
Install
laboratory on PyPI
Before you install
Low friction: pure Python wheel with no runtime dependencies. However, the package is aging—last release was 2019-05-05 and last commit 2025-12-22, so while not abandoned, it receives infrequent updates.
Code with side effects (database writes, file I/O, state mutations) will execute in both control and candidate branches, causing duplicated writes—unsuitable for such operations.
License in practice
MIT license (permissive) means you can use, modify, and distribute this package freely in commercial and private projects with minimal restrictions.
Quickstart
pip install laboratory
import laboratory
experiment = laboratory.Experiment()
experiment.control(old_func, args=[data])
experiment.candidate(new_func, args=[data])
result = experiment.conduct() # returns old_func's value
Verify before relying
- Whether the package still works reliably with modern Python versions beyond those listed in classifiers (3.6 was the latest in the original release metadata).
- Current state of the GitHub repository and whether maintenance is truly active despite the aging status flag.
Package facts
| License | MIT permissive |
| Python support | Not specified |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | None |
| Maintenance | Aging 2,658 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 174,049 / month, #10,293 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 2Programming Language :: Python :: 2.6Programming Language :: Python :: 2.7Programming Language :: Python :: 3Programming Language :: Python :: 3.1Programming Language :: Python :: 3.3Programming Language :: Python :: 3.4Programming Language :: Python :: 3.5Programming Language :: Python :: 3.6Topic :: Software Development :: TestingTopic :: Utilities |
Evidence: laboratory-1.0.2-py2.py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “production code testing”
- laboratoryLaboratory lets you safely refactor critical code paths by running…
- mongomockMongomock provides an in-memory mock of MongoDB collections for…
- gcp-storage-emulatorProvides a local emulator for Google Cloud Storage that intercepts…
Give your agent the search over MCP, or paste the wish link into any chat.
More Utilities packages
Converts domain names between Unicode and ASCII-compatible encoding (Punycode) according to IDNA 2008 and Unicode Technical Standard 46, with security validation and broader script coverage than the standard library.
Install it if you work with internationalized domain names, need to validate domains, or use HTTP clients that depend on it transitively.
Detects and normalizes text encoding from unknown or ambiguous sources, supporting all IANA character sets that Python's core library provides codecs for, with the ability to register custom codecs.
Setuptools is a Python build backend and package management tool that handles building, distributing, and installing Python packages, including support for C/C++ extension modules.
Pluggy provides a plugin system that lets you define hook specifications and register implementations to be called in sequence, enabling extensible Python applications without tight coupling.
Install it if you're building an extensible application or framework.
Pygments is a syntax highlighter that colorizes source code and text in over 500 languages and formats, outputting to HTML, LaTeX, RTF, SVG, images, or ANSI terminal sequences.
Install it if you need to display or transform source code.
Six provides utility functions to write Python code that runs on both Python 2.7 and Python 3.3+, smoothing over language differences between the two versions.
See also dvc · optimizely-sdk · sagemaker-experiments · rope · qiskit-experiments · amplitude-experiment · kaggle-environments · jsoncomparison · haystack-experimental · pure-eval