--- id: random2 version: "1.0.2" license: Python 2.1.1 license_treatment: permissive maintenance: dormant --- # random2 — Python 3 compatible Python 2 `random` Module. License: permissive · Maintenance: dormant · Downloads: 171.2K/mo ## What it is and what it does Random2 is a backport of Python 2.7's random module to Python 3. It exists to solve a specific compatibility problem: Python 3 changed the implementation of randrange(), so even with an identical seed, Python 2 and Python 3 produce different random sequences. This breaks reproducibility in test suites and other code that depends on stable, predictable random output across Python versions. The package provides a drop-in replacement that generates the same sequence as Python 2.7 when given the same seed. It has no external dependencies and installs as a pure Python wheel. It is most useful for porting legacy test code or simulations from Python 2 to Python 3 without having to rewrite all the expected random outputs. Use it for: - Porting Python 2 test suites to Python 3 while keeping random-number expectations unchanged. - Running stochastic simulations or Monte Carlo code that was originally written for Python 2 and requires identical results. - Comparing random-number behavior between Python 2 and Python 3 implementations of the same algorithm. - Reproducing historical results from Python 2 code that relied on specific random sequences. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Provides Python 2.7's random module implementation for Python 3, ensuring identical random sequences when using the same seed across Python versions. Yes, if you are porting Python 2 code to Python 3 and need deterministic random sequences to remain stable. No, if you are writing new Python 3 code—use the native random module instead. The package is dormant but stable, carries no known vulnerabilities, and has minimal friction. It solves a narrow, real problem for legacy code migration. ## Install pip install random2 uv add random2 poetry add random2 ## Installing random2 Before you install: Low install friction with no runtime dependencies. Dormant maintenance status (970 days since last release) but marked Production/Stable and updated to support Python 3.10, 3.11, 3.12, and 3.13 as of 2023-12-18. License in practice: Licensed under Python Software Foundation License (permissive), imposing no significant restrictions on use or redistribution. Quickstart: pip install random2 import random2 random2.seed(0) print(random2.randint(1, 10)) Requires Python 3.10, 3.11, 3.12, or 3.13; earlier Python 3 versions are not supported by version 1.0.2. Verify before relying: - Whether the Python 2.7 random algorithm implementation is mathematically identical to the original or only functionally equivalent for typical use cases. - Performance characteristics compared to Python 3's native random module. - Specific numeric output examples to verify seed reproducibility across Python versions. ## Package facts - License: Python 2.1.1 (permissive) - Python support: unspecified - Install friction: low - Maintenance: dormant - Downloads: 171.2K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags python 2 random module python 3, reproducible random sequences cross-version, python 2.7 random compatibility, stable random generator results, randrange python 2 behavior, seed-stable random numbers, python version random compatibility, python-2-compat, reproducibility, testing [View on SkillFed](https://skillfed.io/packages/random2) · [View on PyPI](https://pypi.org/project/random2/)