Skip to content

Commit 452197a

Browse files
committed
docs: Comprehensive documentation update with detailed docstrings
Major improvements: 1. **README.md**: - Clarified Thread Safety section with detailed explanations - Distinguished between read and write operations - Added concrete examples of thread-safe usage patterns - Explained when external synchronization is needed 2. **src/python_prtree/core.py**: - Added comprehensive docstrings to all classes and methods - Included detailed Args, Returns, Raises, Examples sections - Added performance complexity analysis - Documented thread safety for each method - Added See Also cross-references - Explained precision selection behavior - Provided extensive usage examples for each method 3. **docs/README.md** (new): - Created documentation directory guide - Explained purpose of each subdirectory - Added navigation guide for users and developers Documentation now follows NumPy/Google docstring style with: - Complete parameter descriptions with types - Return value specifications - Exception documentation - Performance characteristics - Thread safety notes - Practical examples for all methods - Cross-references between related methods All README examples verified to work correctly with implementation.
1 parent d7e3e35 commit 452197a

File tree

3 files changed

+669
-69
lines changed

3 files changed

+669
-69
lines changed

README.md

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,33 @@ providing true native precision at each level for better performance and accurac
193193

194194
### Thread Safety
195195

196-
- Query operations are thread-safe
197-
- Insert/erase operations are NOT thread-safe
198-
- Use external synchronization for concurrent updates
196+
**Read Operations (Thread-Safe):**
197+
- `query()` and `batch_query()` are thread-safe when used concurrently from multiple threads
198+
- Multiple threads can safely perform read operations simultaneously
199+
- No external synchronization needed for concurrent queries
200+
201+
**Write Operations (Require Synchronization):**
202+
- `insert()`, `erase()`, and `rebuild()` modify the tree structure
203+
- These operations use internal mutex locks for atomicity
204+
- **Important**: Do NOT perform write operations concurrently with read operations
205+
- Use external synchronization (locks) to prevent concurrent reads and writes
206+
207+
**Recommended Pattern:**
208+
```python
209+
import threading
210+
211+
tree = PRTree2D([1, 2], [[0, 0, 1, 1], [2, 2, 3, 3]])
212+
lock = threading.Lock()
213+
214+
# Multiple threads can query safely without locks
215+
def query_worker():
216+
result = tree.query([0.5, 0.5, 1.5, 1.5]) # Safe without lock
217+
218+
# Write operations need external synchronization
219+
def insert_worker(idx, box):
220+
with lock: # Protect against concurrent reads/writes
221+
tree.insert(idx, box)
222+
```
199223

200224
## Installation from Source
201225

docs/README.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Documentation Directory
2+
3+
This directory contains comprehensive documentation for python_prtree developers and contributors.
4+
5+
## Contents
6+
7+
### Core Documentation
8+
9+
- **[ARCHITECTURE.md](ARCHITECTURE.md)** - Project architecture and design decisions
10+
- Directory structure and separation of concerns
11+
- Data flow diagrams
12+
- Build system overview
13+
- Native precision support architecture
14+
15+
- **[DEVELOPMENT.md](DEVELOPMENT.md)** - Development environment setup
16+
- Prerequisites and installation
17+
- Build instructions
18+
- Testing and code quality tools
19+
- Troubleshooting guide
20+
21+
- **[MIGRATION.md](MIGRATION.md)** - Migration guides between versions
22+
- v0.7.0 project restructuring guide
23+
- Breaking changes and migration steps
24+
- Planned future migrations
25+
26+
### Supplementary Resources
27+
28+
- **baseline/** - Performance baseline measurements
29+
- System information
30+
- Benchmark results and analysis
31+
- Used for regression testing and performance comparison
32+
33+
- **examples/** - Example notebooks and scripts
34+
- Experimental notebooks for exploring the API
35+
- Usage demonstrations
36+
- Prototyping and development examples
37+
38+
- **images/** - Documentation images
39+
- Benchmark graphs used in README
40+
- Performance comparison charts
41+
- Referenced by main documentation
42+
43+
## For Users
44+
45+
If you're a user looking for usage documentation, see:
46+
- [README.md](../README.md) - Main user documentation with examples
47+
- [CONTRIBUTING.md](../CONTRIBUTING.md) - How to contribute to the project
48+
- [CHANGES.md](../CHANGES.md) - Version history and changelog
49+
50+
## For Developers
51+
52+
Start with these files in order:
53+
1. [README.md](../README.md) - Understand what the library does
54+
2. [DEVELOPMENT.md](DEVELOPMENT.md) - Set up your development environment
55+
3. [ARCHITECTURE.md](ARCHITECTURE.md) - Understand the codebase structure
56+
4. [CONTRIBUTING.md](../CONTRIBUTING.md) - Learn the contribution workflow
57+
58+
## Keeping Documentation Updated
59+
60+
When making changes:
61+
- Update ARCHITECTURE.md if you change the project structure
62+
- Update DEVELOPMENT.md if you change build/test processes
63+
- Update MIGRATION.md when introducing breaking changes
64+
- Regenerate benchmarks if performance characteristics change

0 commit comments

Comments
 (0)