fastquadtree 0.4.2__cp38-abi3-win_amd64.whl → 0.5.0__cp38-abi3-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- fastquadtree/_native.pyd +0 -0
- {fastquadtree-0.4.2.dist-info → fastquadtree-0.5.0.dist-info}/METADATA +29 -47
- {fastquadtree-0.4.2.dist-info → fastquadtree-0.5.0.dist-info}/RECORD +5 -5
- {fastquadtree-0.4.2.dist-info → fastquadtree-0.5.0.dist-info}/WHEEL +0 -0
- {fastquadtree-0.4.2.dist-info → fastquadtree-0.5.0.dist-info}/licenses/LICENSE +0 -0
fastquadtree/_native.pyd
CHANGED
Binary file
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: fastquadtree
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.5.0
|
4
4
|
Classifier: Programming Language :: Python :: 3
|
5
5
|
Classifier: Programming Language :: Python :: 3 :: Only
|
6
6
|
Classifier: Programming Language :: Rust
|
@@ -37,7 +37,6 @@ Project-URL: Issues, https://github.com/Elan456/fastquadtree/issues
|
|
37
37
|
[](https://pyo3.rs/)
|
38
38
|
[](https://www.maturin.rs/)
|
39
39
|
[](https://github.com/psf/black)
|
40
|
-
[](http://mypy-lang.org/)
|
41
40
|
|
42
41
|
|
43
42
|

|
@@ -49,6 +48,29 @@ Rust-optimized quadtree with a simple Python API.
|
|
49
48
|
- Python ≥ 3.8
|
50
49
|
- Import path: `from fastquadtree import QuadTree`
|
51
50
|
|
51
|
+
## Benchmarks
|
52
|
+
|
53
|
+
fastquadtree **outperforms** all other quadtree Python packages, including the Rtree spatial index.
|
54
|
+
|
55
|
+
### Library comparison
|
56
|
+
|
57
|
+

|
58
|
+

|
59
|
+
|
60
|
+
### Summary (largest dataset, PyQtree baseline)
|
61
|
+
- Points: **500,000**, Queries: **500**
|
62
|
+
--------------------
|
63
|
+
- Fastest total: **fastquadtree** at **1.591 s**
|
64
|
+
|
65
|
+
| Library | Build (s) | Query (s) | Total (s) | Speed vs PyQtree |
|
66
|
+
|---|---:|---:|---:|---:|
|
67
|
+
| fastquadtree | 0.165 | 1.427 | 1.591 | 5.09× |
|
68
|
+
| Rtree | 1.320 | 2.369 | 3.688 | 2.20× |
|
69
|
+
| PyQtree | 2.687 | 5.415 | 8.102 | 1.00× |
|
70
|
+
| nontree-QuadTree | 1.284 | 9.891 | 11.175 | 0.73× |
|
71
|
+
| quads | 2.346 | 10.129 | 12.475 | 0.65× |
|
72
|
+
| e-pyquadtree | 1.795 | 11.855 | 13.650 | 0.59× |
|
73
|
+
|
52
74
|
## Install
|
53
75
|
|
54
76
|
```bash
|
@@ -109,25 +131,7 @@ print(f"Deleted player: {deleted}") # True
|
|
109
131
|
|
110
132
|
You can keep the tree pure and manage your own id → object map, or let the wrapper manage it.
|
111
133
|
|
112
|
-
**
|
113
|
-
|
114
|
-
```python
|
115
|
-
from fastquadtree import QuadTree
|
116
|
-
|
117
|
-
qt = QuadTree((0, 0, 1000, 1000), capacity=16)
|
118
|
-
objects: dict[int, object] = {}
|
119
|
-
|
120
|
-
def add(obj) -> int:
|
121
|
-
obj_id = qt.insert(obj.position) # auto id
|
122
|
-
objects[obj_id] = obj
|
123
|
-
return obj_id
|
124
|
-
|
125
|
-
# Later, resolve ids back to objects
|
126
|
-
ids = [obj_id for (obj_id, x, y) in qt.query((100, 100, 300, 300))]
|
127
|
-
selected = [objects[i] for i in ids]
|
128
|
-
```
|
129
|
-
|
130
|
-
**Option B: Ask the wrapper to track objects**
|
134
|
+
**Wrapper Managed Objects**
|
131
135
|
|
132
136
|
```python
|
133
137
|
from fastquadtree import QuadTree
|
@@ -137,7 +141,7 @@ qt = QuadTree((0, 0, 1000, 1000), capacity=16, track_objects=True)
|
|
137
141
|
# Store the object alongside the point
|
138
142
|
qt.insert((25, 40), obj={"name": "apple"})
|
139
143
|
|
140
|
-
# Ask for Item objects
|
144
|
+
# Ask for Item objects within a bounding box
|
141
145
|
items = qt.query((0, 0, 100, 100), as_items=True)
|
142
146
|
for it in items:
|
143
147
|
print(it.id, it.x, it.y, it.obj)
|
@@ -151,7 +155,7 @@ qt.attach(123, my_object) # binds object to id 123
|
|
151
155
|
|
152
156
|
## API
|
153
157
|
|
154
|
-
### `QuadTree(bounds, capacity,
|
158
|
+
### `QuadTree(bounds, capacity, max_depth=None, track_objects=False, start_id=1)`
|
155
159
|
|
156
160
|
* `bounds` — tuple `(min_x, min_y, max_x, max_y)` defines the 2D area covered by the quadtree
|
157
161
|
* `capacity` — max number of points kept in a leaf before splitting
|
@@ -204,30 +208,8 @@ Full docs are in the docstrings of the [Python Shim](pysrc/fastquadtree/__init__
|
|
204
208
|
* For fastest local runs, use `maturin develop --release`.
|
205
209
|
* The wrapper keeps Python overhead low: raw tuple results by default, `Item` wrappers only when requested.
|
206
210
|
|
207
|
-
## Benchmarks
|
208
|
-
|
209
|
-
fastquadtree outperforms all other quadtree python packages (at least all the ones I could find and install via pip.)
|
210
|
-
|
211
|
-
### Library comparison
|
212
|
-
|
213
|
-

|
214
|
-

|
215
|
-
|
216
|
-
### Summary (largest dataset, PyQtree baseline)
|
217
|
-
- Points: **500,000**, Queries: **500**
|
218
|
-
- Fastest total: **fastquadtree** at **2.207 s**
|
219
|
-
|
220
|
-
| Library | Build (s) | Query (s) | Total (s) | Speed vs PyQtree |
|
221
|
-
|---|---:|---:|---:|---:|
|
222
|
-
| fastquadtree | 0.321 | 1.885 | 2.207 | 4.27× |
|
223
|
-
| Rtree | 1.718 | 4.376 | 6.095 | 1.55× |
|
224
|
-
| nontree-QuadTree | 1.617 | 7.643 | 9.260 | 1.02× |
|
225
|
-
| PyQtree | 4.349 | 5.082 | 9.431 | 1.00× |
|
226
|
-
| quads | 3.874 | 9.058 | 12.932 | 0.73× |
|
227
|
-
| e-pyquadtree | 2.732 | 10.598 | 13.330 | 0.71× |
|
228
|
-
| Brute force | 0.019 | 19.986 | 20.005 | 0.47× |
|
229
211
|
|
230
|
-
### Native vs Shim
|
212
|
+
### Native vs Shim Benchmark
|
231
213
|
|
232
214
|
**Setup**
|
233
215
|
- Points: 500,000
|
@@ -277,7 +259,7 @@ Check the CLI arguments for the cross-library benchmark in `benchmarks/quadtree_
|
|
277
259
|
Allowed. For k-nearest, duplicates are de-duplicated by id. For range queries you will see every inserted point.
|
278
260
|
|
279
261
|
**Can I delete items from the quadtree?**
|
280
|
-
Yes! Use `delete(id, xy)` to remove specific items. You must provide both the ID and exact location for precise deletion. This handles cases where multiple items exist at the same location. If you're using `track_objects=True`, you can also use `delete_by_object(obj
|
262
|
+
Yes! Use `delete(id, xy)` to remove specific items. You must provide both the ID and exact location for precise deletion. This handles cases where multiple items exist at the same location. If you're using `track_objects=True`, you can also use `delete_by_object(obj)` for convenient object-based deletion with O(1) lookup. The tree automatically merges nodes when item counts drop below capacity.
|
281
263
|
|
282
264
|
**Can I store rectangles or circles?**
|
283
265
|
The core stores points. To index objects with extent, insert whatever representative point you choose. For rectangles you can insert centers or build an AABB tree separately.
|
@@ -1,10 +1,10 @@
|
|
1
|
-
fastquadtree-0.
|
2
|
-
fastquadtree-0.
|
3
|
-
fastquadtree-0.
|
1
|
+
fastquadtree-0.5.0.dist-info/METADATA,sha256=7TPGeXEmmg20TEZc2Wx3gAiGMzdTuklhapwtEbn8IrQ,10119
|
2
|
+
fastquadtree-0.5.0.dist-info/WHEEL,sha256=7bfl5v0wbVhXZba613g0x-n2obNNfpQuN8I1cQ4oaU8,94
|
3
|
+
fastquadtree-0.5.0.dist-info/licenses/LICENSE,sha256=46IVFhoCIwMo-ocq4olyEB1eBvvtaKic5yGLeKXnDuc,1092
|
4
4
|
fastquadtree/__init__.py,sha256=rqttCrFBaqMjD7BDZlcwkU9eeOQh2gzRi81xKHHLwLk,12652
|
5
5
|
fastquadtree/__init__.pyi,sha256=4lKaqtnvylRzhj322ue_y_DO_xxrkzOzjpYnH5SN1Fg,2166
|
6
6
|
fastquadtree/_bimap.py,sha256=zMp20NJkvVuO3jn2OeVApf7j4siBI4r2kU6SHyb7EZE,3428
|
7
7
|
fastquadtree/_item.py,sha256=imyiwnbmY21mHsOvNqB4j-TsOPpAmsvb38LKxEL8q4o,526
|
8
|
-
fastquadtree/_native.pyd,sha256=
|
8
|
+
fastquadtree/_native.pyd,sha256=84XbRhl0Lj2ofRahwDK4Pjw_JiXvOVHfEFGD8hHbbJ0,247808
|
9
9
|
fastquadtree/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
10
|
-
fastquadtree-0.
|
10
|
+
fastquadtree-0.5.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|