A comprehensive benchmarking suite to evaluate and compare Python performance across different versions: Python 3.13, Python 3.14, and Python 3.14 threadfree.
This repository contains performance tests designed to measure and analyze the execution characteristics of different Python versions. The benchmarks cover various computational patterns including CPU-intensive tasks, memory operations, and language feature performance.
This project uses uv for fast Python package and environment management.
-
Install uv (if not already installed):
powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
-
Set up all Python environments:
REM For Windows CMD setup.bat REM For Git Bash on Windows bash setup-gitbash.sh
If you prefer to set up manually:
REM Create Python 3.13 environment
uv venv --python 3.13 venv-3.13
venv-3.13\Scripts\activate.bat
uv pip install -e .
deactivate
REM Create Python 3.14 environment
uv venv --python 3.14 venv-3.14
venv-3.14\Scripts\activate.bat
uv pip install -e .
deactivate
REM Create Python 3.14 threadfree environment
uv venv --python 3.14t venv-3.14-threadfree
venv-3.14-threadfree\Scripts\activate.bat
uv pip install -e .
deactivateREM Switch to Python 3.13
venv-3.13\Scripts\activate.bat
REM Switch to Python 3.14
venv-3.14\Scripts\activate.bat
REM Switch to Python 3.14 threadfree
venv-3.14-threadfree\Scripts\activate.bat# Switch to Python 3.13
source venv-3.13/Scripts/activate
# Switch to Python 3.14
source venv-3.14/Scripts/activate
# Switch to Python 3.14 threadfree
source venv-3.14-threadfree/Scripts/activateYou can run the same script with different Python versions without switching environments:
venv-3.13\Scripts\python.exe benchmark.py
venv-3.14\Scripts\python.exe benchmark.py
venv-3.14-threadfree\Scripts\python.exe benchmark.pyvenv-3.13/Scripts/python.exe benchmark.py
venv-3.14/Scripts/python.exe benchmark.py
venv-3.14-threadfree/Scripts/python.exe benchmark.pyThe following benchmarks are implemented to evaluate different aspects of Python performance:
- Fibonacci Sequence Calculation - CPU-intensive recursive algorithm to test recursion performance and stack management
- Bubble Sort Algorithm - CPU-intensive iterative algorithm to test loop performance and array operations
- list/Dict/Set Comprehensions - Memory allocation and iteration patterns for data structure operations
- Function Call Overhead - Repeated function calls to measure call stack performance and overhead
- Exception Handling - try/except/finally clause performance to test error handling mechanisms
- Object Instantiation - Class object creation with varying complexity:
- No attributes
- Simple attributes
- Nested complex data attributes
- Attribute Access - Object attribute access patterns (e.g.,
object.attribute)
Each benchmark is designed to:
- Measure execution time using high-precision timing
- Track memory usage and allocation patterns
- Generate statistical analysis of performance differences
- Provide reproducible results across different Python versions
python-performance-test/
├── venv-3.13/ # Python 3.13 virtual environment
├── venv-3.14/ # Python 3.14 virtual environment
├── venv-3.14-threadfree/ # Python 3.14 threadfree virtual environment
├── benchmark.py # Example benchmark script
├── setup.bat # Windows CMD setup script
├── setup-gitbash.sh # Git Bash setup script
├── pyproject.toml # Project configuration
└── README.md
-
Set up the project:
REM For Windows CMD setup.bat REM For Git Bash on Windows bash setup-gitbash.sh
-
Run the same script with different Python versions:
REM Windows CMD venv-3.13\Scripts\python.exe benchmark.py venv-3.14\Scripts\python.exe benchmark.py venv-3.14-threadfree\Scripts\python.exe benchmark.py# Git Bash on Windows venv-3.13/Scripts/python.exe benchmark.py venv-3.14/Scripts/python.exe benchmark.py venv-3.14-threadfree/Scripts/python.exe benchmark.py -
Compare performance results across the different Python versions.
- uv - Fast Python package manager
- Python 3.13+ - Base Python version
- Virtual environment support - For isolated testing environments
- Performance measurement tools - timeit, cProfile, memory_profiler
- uv not found: Make sure uv is installed and in your PATH
- Python version not available: Ensure the Python version is installed on your system
- Virtual environment creation fails: Check disk space and permissions
- Dependencies installation fails: Verify internet connection and try updating uv
- Check the uv documentation
- Review the project's issue tracker
- Ensure all system requirements are met