A repository dedicated to exploring and implementing efficient, "Pythonic" data structures and algorithms, with a focus on performance benchmarking and modern development practices.
This project uses uv for dependency management and Task for automation.
- uv (Extremely fast Python package installer and resolver)
- Task (A task runner / simpler alternative to Make)
-
Clone the repository:
git clone https://github.com/NavneetSinghArora/pythonic-structures.git cd pythonic-structures -
Setup the environment:
uv sync
-
Install pre-commit hooks:
uv run pre-commit install
We use Taskfile to manage common development tasks. You can run task --list to see all available commands.
| Command | Description |
|---|---|
task tests |
Run all tests (including benchmarks) |
task tests-only |
Run unit tests only |
task benchmarks |
Run performance benchmarks |
task format |
Format and fix linting issues with Ruff |
task lint |
Check for linting issues |
If you prefer using uv directly:
- Run tests:
uv run pytest - Format code:
uv run ruff format .
sorting/: Implementations of various sorting algorithms.utils/: Utility functions and decorators (e.g., performance timers).tests/: Unit tests for ensuring correctness.benchmarks/: Performance tests and result tracking.
- CPU: Apple M4
- Architecture: arm64
- Python: 3.14.2
- OS: Darwin 25.2.0
| Algorithm | Mean | Min | Max | Std Dev | Ops/s | Rounds |
|---|---|---|---|---|---|---|
| Native Sort | 260.90 ns | 228.05 ns | 3.66 µs | 32.68 ns | 3.83M ops/s | 195,123 |
| Bubble Sort | 15.89 µs | 15.04 µs | 682.25 µs | 7.17 µs | 62.93K ops/s | 9,026 |
| Insertion Sort | 52.67 µs | 49.33 µs | 503.79 µs | 6.88 µs | 18.99K ops/s | 13,023 |