@@ -6,10 +6,20 @@ Thank you for taking the time to contribute ❤️
66
77## Requirements
88
9- - Linux or macOS (the development workflow is primarily tested on Unix-like systems)
10- - A supported Python version (e.g. Python 3.10+; latest tested: Python 3.14)
9+ ### Core requirements (all contributors)
10+
11+ - Linux or macOS (development is primarily tested on Unix-like systems)
12+ - A supported Python version (Python ** 3.10+** ; latest tested: ** Python 3.14** )
1113- [ ` uv ` ] ( https://astral.sh/uv/ ) – fast Python package manager and environment tool
1214
15+ ### Optional (for Rust acceleration work)
16+
17+ - Rust toolchain (` rustc ` , ` cargo ` )
18+ - [ ` maturin ` ] ( https://www.maturin.rs/ ) (installed automatically via ` uv ` if needed)
19+
20+ > Rust is ** optional** .
21+ > The project must always work in pure Python mode.
22+
1323## Installation
1424
1525### 1. Fork & clone
@@ -20,7 +30,6 @@ Thank you for taking the time to contribute ❤️
2030``` bash
2131git clone https://github.com/akhundMurad/typeid-python.git
2232cd typeid-python
23- ```
2433
2534# ## 2. Install `uv`
2635
@@ -50,6 +59,8 @@ This will:
5059
5160# # Running tests
5261
62+ Run the full test suite:
63+
5364` ` ` bash
5465make test
5566` ` `
@@ -60,9 +71,68 @@ or directly:
6071uv run pytest -v
6172` ` `
6273
74+ Tests are expected to pass in ** both** :
75+
76+ - pure Python mode
77+ - Rust-accelerated mode (if available)
78+
79+ # # Rust acceleration (optional)
80+
81+ TypeID includes an ** optional Rust extension** used for performance-critical paths
82+ (e.g. base32 encode/decode).
83+
84+ # ## Building the Rust extension locally
85+
86+ If you have Rust installed:
87+
88+ ` ` ` bash
89+ cd rust-base32
90+ maturin develop
91+ ` ` `
92+
93+ This installs the native extension into the active virtual environment.
94+
95+ You can verify which backend is active via tests.
96+
97+ # ## Testing Python fallback explicitly
98+
99+ Contributors ** must not break** the pure Python fallback.
100+
101+ To test fallback behavior:
102+
103+ ` ` ` bash
104+ pytest tests/test_base32.py
105+ ` ` `
106+
107+ This suite verifies that:
108+
109+ - Rust is used when available
110+ - Python fallback is used when Rust is unavailable
111+
112+ # # Benchmarks (performance-sensitive changes)
113+
114+ If your change affects performance-sensitive code paths (generation, parsing, base32):
115+
116+ Run benchmarks locally:
117+
118+ ` ` ` bash
119+ ./bench/run.sh
120+ ` ` `
121+
122+ Benchmark results are:
123+
124+ - reproducible
125+ - stored as raw JSON
126+ - compared across versions
127+
128+ When making performance claims, include:
129+
130+ - before/after numbers
131+ - raw benchmark JSON (if applicable)
132+
63133# # Formatters & linters
64134
65- We use the following tools :
135+ We use:
66136
67137- ** ruff** – linting & import sorting
68138- ** black** – code formatting
@@ -74,7 +144,7 @@ Run all linters:
74144make check-linting
75145` ` `
76146
77- Auto-fix formatting issues where possible:
147+ Auto-fix formatting where possible:
78148
79149` ` ` bash
80150make fix-linting
@@ -90,6 +160,8 @@ make build
90160
91161This uses ` uv build` under the hood.
92162
163+ Rust wheels are built automatically in CI when applicable.
164+
93165# # Testing extras (CLI)
94166
95167To test the CLI extra locally:
@@ -102,29 +174,40 @@ uv run typeid new -p test
102174# # Lockfile discipline
103175
104176- ` uv.lock` ** must be committed**
105- - Always run dependency changes via ` uv add ` / ` uv remove `
106- - CI uses ` uv sync --locked ` , so lockfile drift will fail builds
177+ - Always change dependencies via ` uv add` / ` uv remove`
178+ - CI uses ` uv sync --locked`
179+ - Lockfile drift will fail builds
107180
108- ## How to name branches
181+ # # Branch naming
109182
110183Branch names are flexible, as long as they are respectful and descriptive.
111184
112185Recommended patterns:
113186
114187- ` fix/core/32`
115- - ` feature/cli-support `
188+ - ` feature/rust-base32`
189+ - ` perf/lazy-uuid`
116190- ` docs/readme-update`
117191- ` chore/ci-cleanup`
118192
119- Referencing an issue number in the branch name is encouraged but not required.
193+ Referencing an issue number is encouraged but not required.
120194
121195# # Submitting a Pull Request
122196
1231971. Create a feature branch
124- 2 . Make sure tests and linters pass
125- 3 . Commit with a clear message
126- 4 . Open a pull request against ` main `
127- 5 . Describe ** what** changed and ** why**
198+ 2. Ensure tests and linters pass
199+ 3. Ensure Python fallback still works
200+ 4. Commit with a clear message
201+ 5. Open a pull request against ` main`
202+ 6. Describe ** what** changed and ** why**
203+
204+ Performance-related PRs should explain:
205+
206+ - which path was optimized
207+ - what benchmark changed
208+ - why the change is safe
209+
210+ ---
128211
129212Happy hacking 🚀
130- If something is unclear, feel free to open an issue or discussion.
213+ If anything is unclear, feel free to open an issue or discussion.
0 commit comments