Description
Quicksect is a fast python / cython implementation of interval search based on the pure python version in bx-python I pulled it out, optimized and converted to cython and James Taylor has incoporated it back into bx-python with his improvements.
I have brought this project back from the dead because I want a fast, simple, no-dependencies Interval tree.
(https://github.com/brentp/quicksect)
Extended with removal operations and allows pretty print to display tree structure (By Jianlin)
License is MIT.
Installation
pip install quicksectx
Use
To use extended quicksect(quicksectx):
>>> from quicksectx import IntervalNode, IntervalTree, Interval >>> tree = IntervalTree() >>> tree.add(1, 3, 100) >>> tree.add(3, 7, 110) >>> tree.add(2, 5, 120) >>> tree.add(4, 6, 130) >>> print(tree.pretty_print()) Inv(1, 3, d=100) r: Inv(3, 7, d=110) l: Inv(2, 5, d=120) r: Inv(4, 6, d=130) >>> print(tree.find(Interval(2, 5))) [Inv(1, 3, d=100), Inv(3, 7, d=110), Inv(2, 5, d=120), Inv(4, 6, d=130)] >>> tree.remove(Interval(2, 5)) >>> print(tree.find(Interval(2, 5))) [Inv(1, 3, d=100), Inv(3, 7, d=110), Inv(4, 6, d=130)]
To use traditional quicksect, you can still using the same syntax:
>>> from quicksect import IntervalNode, Interval, IntervalTree
Most common use will be via IntervalTree:
>>> tree = IntervalTree() >>> tree.add(23, 45) >>> tree.add(55, 66) >>> tree.search(46, 47) [] >>> tree.search(44, 56) [Interval(55, 66), Interval(23, 45)]>>> tree.insert(Interval(88, 444, 'a')) >>> res = tree.find(Interval(99, 100, 'b')) >>> res [Interval(88, 444)] >>> res[0].start, res[0].end, res[0].data (88, 444, 'a')
Thats pretty much everything you need to know about the tree.
Test
$ python setup.py test
Low-Level
In some cases, users may want to utilize the lower-level interface that accesses the nodes of the tree:
>>> inter = IntervalNode(Interval(22, 33)) >>> inter = inter.insert(Interval(44, 55)) >>> inter.intersect(24, 26) [Interval(22, 33)]>>> inter.left(Interval(34, 35), n=1) [Interval(22, 33)]>>> inter.right(Interval(34, 35), n=1) [Interval(44, 55)]
Since 0.3.7, you can use python’s native pickle to pickle an IntervalTree object. For details, check test_serialization.py
For Dev
Now the version specification has been integrated with setup.py and pyproject.toml. To update versions, only need to change the __version__ in quicksectx/__init__.py
Release files for quicksectx 0.4.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| quicksectx-0.4.1.tar.gz | 238.2 kB | Details |
Built distributions (wheels)
Total release size: 9.8 MB
Release files / quicksectx-0.4.1.tar.gz
| Download URL | quicksectx-0.4.1.tar.gz |
|---|---|
| Size | 238.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
91a51ab80a27c65ed80a7e23819566b629249c53eb50c149901fcdf3362fe1ca
|
|
BLAKE2b-256 checksum How to use checksums |
02afca3bbd43cf15de91d86fdab55cfdff4da7e1a3321936f64d0fc6fc7f276c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.8.18
|
Release files / quicksectx-0.4.1-cp312-cp312-win_amd64.whl
| Download URL | quicksectx-0.4.1-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 356.9 kB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
9dc7380b2954a36fde4d5db621c3576deb7b6697b2bd73160c9f4975fc344dae
|
|
BLAKE2b-256 checksum How to use checksums |
0fe37d336dde67415ac234f140647ef30e527f597751862cda595c99b7251b3b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.8.18
|
Release files / quicksectx-0.4.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | quicksectx-0.4.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 1.1 MB |
| Tags | CPython 3.12 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
4a9eb3fa7b18e9367b617e628806e826363d23915fa2daa9316d7d0080fed369
|
|
BLAKE2b-256 checksum How to use checksums |
7c85dccdb07ce15f1031141cc3aebd9d2f52fdcb63f18e825e0d49bc8df081d5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.8.18
|
Release files / quicksectx-0.4.1-cp312-cp312-macosx_10_13_universal2.whl
| Download URL | quicksectx-0.4.1-cp312-cp312-macosx_10_13_universal2.whl |
|---|---|
| Size | 505.7 kB |
| Tags | CPython 3.12 macOS 10.13+ universal2 (ARM64, x86-64) |
|
SHA-256 checksum How to use checksums |
b8938929cf893d9d0d6e74feae74539beef55fbf287fea0bc996752cd5fca54f
|
|
BLAKE2b-256 checksum How to use checksums |
03fbcac712452a063fe4ca09dcbd52b8a867300198bde6134e9e75bde847c86b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.8.18
|
Release files / quicksectx-0.4.1-cp311-cp311-win_amd64.whl
| Download URL | quicksectx-0.4.1-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 356.8 kB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
88af6881b9b21aabcf58474f41ff98cf3d60fc4c8c785765330741cfb0132a08
|
|
BLAKE2b-256 checksum How to use checksums |
71c062dc0af017b8bd822f09b864d8cd39a7fd2b33054e12be74707b21056b28
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.8.18
|
Release files / quicksectx-0.4.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | quicksectx-0.4.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 1.1 MB |
| Tags | CPython 3.11 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
e9f2bb93adf5c6d39f3d55ca87a4a017bb2823e5a235b27ace0a39b3c381294d
|
|
BLAKE2b-256 checksum How to use checksums |
358bdb3b5019f9e833ca33466a35bdd7d30cc8be6dbeb0ea4328dcfee9758f69
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.8.18
|
Release files / quicksectx-0.4.1-cp311-cp311-macosx_10_9_universal2.whl
| Download URL | quicksectx-0.4.1-cp311-cp311-macosx_10_9_universal2.whl |
|---|---|
| Size | 506.0 kB |
| Tags | CPython 3.11 macOS 10.9+ universal2 (ARM64, x86-64) |
|
SHA-256 checksum How to use checksums |
98d0e3f1708828d0cefcf3c3a46143b562a35f0bdf8f85610d9599e8dff3a9c0
|
|
BLAKE2b-256 checksum How to use checksums |
bdd996d3c7a15e57a59d15a94a851224ea9201ddaab53c10c53e6e586ad53039
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.8.18
|
Release files / quicksectx-0.4.1-cp310-cp310-win_amd64.whl
| Download URL | quicksectx-0.4.1-cp310-cp310-win_amd64.whl |
|---|---|
| Size | 356.5 kB |
| Tags | CPython 3.10 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
2367db2333170159affa50cfb530142c3a010d64cad83e598bdd1fb5b5223229
|
|
BLAKE2b-256 checksum How to use checksums |
241cdfc159cca8d258517435f65f71a032b0fcf94f1f7b5620288fcf5e281950
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.8.18
|
Release files / quicksectx-0.4.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | quicksectx-0.4.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 1.0 MB |
| Tags | CPython 3.10 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
7c9edd08c948bc749634fe9333eae9a820cc38ba4911babc23efbd18f968b62e
|
|
BLAKE2b-256 checksum How to use checksums |
46dd6fc9b98752f41cb92d511dbd1339f966f09d412cbe07ebb73c054c3598e7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.8.18
|
Release files / quicksectx-0.4.1-cp310-cp310-macosx_10_9_universal2.whl
| Download URL | quicksectx-0.4.1-cp310-cp310-macosx_10_9_universal2.whl |
|---|---|
| Size | 505.1 kB |
| Tags | CPython 3.10 macOS 10.9+ universal2 (ARM64, x86-64) |
|
SHA-256 checksum How to use checksums |
36a2254750555a33281b1ca259e45338cce413a56c6b83dc145b61d50c7cde02
|
|
BLAKE2b-256 checksum How to use checksums |
8cdf370a1e9465563261310c28104caedf966553ee2193aeb9b481ea16c75b35
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.8.18
|
Release files / quicksectx-0.4.1-cp39-cp39-win_amd64.whl
| Download URL | quicksectx-0.4.1-cp39-cp39-win_amd64.whl |
|---|---|
| Size | 356.7 kB |
| Tags | CPython 3.9 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
ed13aadcf0023eef1b91141133d8b57a0aa426ca1f0a4f1ad88d4aa4d41303c5
|
|
BLAKE2b-256 checksum How to use checksums |
bdee6f7ce5f2fd8a6caf289dc5cbcc884cf8cc4f3ae8483b8d8ab58180378e1b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.8.18
|
Release files / quicksectx-0.4.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | quicksectx-0.4.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 1.0 MB |
| Tags | CPython 3.9 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
086e1e4e7541c2a57be23067ddbc3cb13bbd68bc9977dba7bdd4e229fdb8c04f
|
|
BLAKE2b-256 checksum How to use checksums |
3d1bdf5e13e072982ebf9146e697acd5666f31abc50f920c13e3aa2019a3c561
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.8.18
|
Release files / quicksectx-0.4.1-cp39-cp39-macosx_10_9_universal2.whl
| Download URL | quicksectx-0.4.1-cp39-cp39-macosx_10_9_universal2.whl |
|---|---|
| Size | 506.3 kB |
| Tags | CPython 3.9 macOS 10.9+ universal2 (ARM64, x86-64) |
|
SHA-256 checksum How to use checksums |
80d7bb802fcb4605bfd82a661856f250c9bbe1941c19f7e4b30ec487126c2659
|
|
BLAKE2b-256 checksum How to use checksums |
ee575cbfc139725df4b945237fd969f37c50aa1b7f08256f6bd8eabc8021722d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.8.18
|
Release files / quicksectx-0.4.1-cp38-cp38-win_amd64.whl
| Download URL | quicksectx-0.4.1-cp38-cp38-win_amd64.whl |
|---|---|
| Size | 357.2 kB |
| Tags | CPython 3.8 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
d21c7e214337c40551dea0e9f6b942ac5237938234e0b85ce40121dcbd0c8390
|
|
BLAKE2b-256 checksum How to use checksums |
108340f7ba89d40414123f3bbd059f73db343c5c988df8e46542f4d6fdb4d101
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.8.18
|
Release files / quicksectx-0.4.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | quicksectx-0.4.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 1.0 MB |
| Tags | CPython 3.8 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
21e7123982f6e33f8b25b9f0f102c80f900fba0cebfec4c14a17a81a987eb24c
|
|
BLAKE2b-256 checksum How to use checksums |
7670c04db91cba26d257c1ebcacf0565e0cbbf7a2861336a8a7deca039e1f414
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.8.18
|
Release files / quicksectx-0.4.1-cp38-cp38-macosx_10_9_universal2.whl
| Download URL | quicksectx-0.4.1-cp38-cp38-macosx_10_9_universal2.whl |
|---|---|
| Size | 506.4 kB |
| Tags | CPython 3.8 macOS 10.9+ universal2 (ARM64, x86-64) |
|
SHA-256 checksum How to use checksums |
60531878a5d010b2ff67d2ea648fd7e3e70ba81871388e02a588be6e290ba6b7
|
|
BLAKE2b-256 checksum How to use checksums |
2b3cc59c57bce3a14711ce05e7a80f29f51cf03f45c191a3d12990157e253632
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.8.18
|