Skip to main content

Quicksect is a fast python / cython implementation of interval search.

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

quicksectx-0.4.1.tar.gz (238.2 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

quicksectx-0.4.1-cp312-cp312-win_amd64.whl (356.9 kB view details)

Uploaded CPython 3.12Windows x86-64

quicksectx-0.4.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

quicksectx-0.4.1-cp312-cp312-macosx_10_13_universal2.whl (505.7 kB view details)

Uploaded CPython 3.12macOS 10.13+ universal2 (ARM64, x86-64)

quicksectx-0.4.1-cp311-cp311-win_amd64.whl (356.8 kB view details)

Uploaded CPython 3.11Windows x86-64

quicksectx-0.4.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

quicksectx-0.4.1-cp311-cp311-macosx_10_9_universal2.whl (506.0 kB view details)

Uploaded CPython 3.11macOS 10.9+ universal2 (ARM64, x86-64)

quicksectx-0.4.1-cp310-cp310-win_amd64.whl (356.5 kB view details)

Uploaded CPython 3.10Windows x86-64

quicksectx-0.4.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

quicksectx-0.4.1-cp310-cp310-macosx_10_9_universal2.whl (505.1 kB view details)

Uploaded CPython 3.10macOS 10.9+ universal2 (ARM64, x86-64)

quicksectx-0.4.1-cp39-cp39-win_amd64.whl (356.7 kB view details)

Uploaded CPython 3.9Windows x86-64

quicksectx-0.4.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

quicksectx-0.4.1-cp39-cp39-macosx_10_9_universal2.whl (506.3 kB view details)

Uploaded CPython 3.9macOS 10.9+ universal2 (ARM64, x86-64)

quicksectx-0.4.1-cp38-cp38-win_amd64.whl (357.2 kB view details)

Uploaded CPython 3.8Windows x86-64

quicksectx-0.4.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

quicksectx-0.4.1-cp38-cp38-macosx_10_9_universal2.whl (506.4 kB view details)

Uploaded CPython 3.8macOS 10.9+ universal2 (ARM64, x86-64)

File details

Details for the file quicksectx-0.4.1.tar.gz.

File metadata

  • Download URL: quicksectx-0.4.1.tar.gz
  • Upload date:
  • Size: 238.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.18

File hashes

Hashes for quicksectx-0.4.1.tar.gz
Algorithm Hash digest
SHA256 91a51ab80a27c65ed80a7e23819566b629249c53eb50c149901fcdf3362fe1ca
MD5 90ccfd8c3be26f69c9c96413504b7234
BLAKE2b-256 02afca3bbd43cf15de91d86fdab55cfdff4da7e1a3321936f64d0fc6fc7f276c

See more details on using hashes here.

File details

Details for the file quicksectx-0.4.1-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: quicksectx-0.4.1-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 356.9 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.18

File hashes

Hashes for quicksectx-0.4.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 9dc7380b2954a36fde4d5db621c3576deb7b6697b2bd73160c9f4975fc344dae
MD5 d4a7d43aac083a2b1a5c1d2bdd514cc7
BLAKE2b-256 0fe37d336dde67415ac234f140647ef30e527f597751862cda595c99b7251b3b

See more details on using hashes here.

File details

Details for the file quicksectx-0.4.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for quicksectx-0.4.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4a9eb3fa7b18e9367b617e628806e826363d23915fa2daa9316d7d0080fed369
MD5 9a5c0b6e85e84911ebd666718acb29eb
BLAKE2b-256 7c85dccdb07ce15f1031141cc3aebd9d2f52fdcb63f18e825e0d49bc8df081d5

See more details on using hashes here.

File details

Details for the file quicksectx-0.4.1-cp312-cp312-macosx_10_13_universal2.whl.

File metadata

File hashes

Hashes for quicksectx-0.4.1-cp312-cp312-macosx_10_13_universal2.whl
Algorithm Hash digest
SHA256 b8938929cf893d9d0d6e74feae74539beef55fbf287fea0bc996752cd5fca54f
MD5 8f5b6682ab54865d1bc51a08e2f3cc23
BLAKE2b-256 03fbcac712452a063fe4ca09dcbd52b8a867300198bde6134e9e75bde847c86b

See more details on using hashes here.

File details

Details for the file quicksectx-0.4.1-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: quicksectx-0.4.1-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 356.8 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.18

File hashes

Hashes for quicksectx-0.4.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 88af6881b9b21aabcf58474f41ff98cf3d60fc4c8c785765330741cfb0132a08
MD5 f3d1d25582891a06d83108ea1eecba4c
BLAKE2b-256 71c062dc0af017b8bd822f09b864d8cd39a7fd2b33054e12be74707b21056b28

See more details on using hashes here.

File details

Details for the file quicksectx-0.4.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for quicksectx-0.4.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e9f2bb93adf5c6d39f3d55ca87a4a017bb2823e5a235b27ace0a39b3c381294d
MD5 653a71c56f3e524730ffb8c2f575f28b
BLAKE2b-256 358bdb3b5019f9e833ca33466a35bdd7d30cc8be6dbeb0ea4328dcfee9758f69

See more details on using hashes here.

File details

Details for the file quicksectx-0.4.1-cp311-cp311-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for quicksectx-0.4.1-cp311-cp311-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 98d0e3f1708828d0cefcf3c3a46143b562a35f0bdf8f85610d9599e8dff3a9c0
MD5 2b8da70a287effb193c0d7c0a928cf7b
BLAKE2b-256 bdd996d3c7a15e57a59d15a94a851224ea9201ddaab53c10c53e6e586ad53039

See more details on using hashes here.

File details

Details for the file quicksectx-0.4.1-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: quicksectx-0.4.1-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 356.5 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.18

File hashes

Hashes for quicksectx-0.4.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 2367db2333170159affa50cfb530142c3a010d64cad83e598bdd1fb5b5223229
MD5 44990b94070759fc7466c4e396d8922e
BLAKE2b-256 241cdfc159cca8d258517435f65f71a032b0fcf94f1f7b5620288fcf5e281950

See more details on using hashes here.

File details

Details for the file quicksectx-0.4.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for quicksectx-0.4.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7c9edd08c948bc749634fe9333eae9a820cc38ba4911babc23efbd18f968b62e
MD5 6921b19fc4ca772fa6df85f994a06eed
BLAKE2b-256 46dd6fc9b98752f41cb92d511dbd1339f966f09d412cbe07ebb73c054c3598e7

See more details on using hashes here.

File details

Details for the file quicksectx-0.4.1-cp310-cp310-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for quicksectx-0.4.1-cp310-cp310-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 36a2254750555a33281b1ca259e45338cce413a56c6b83dc145b61d50c7cde02
MD5 560dc7ccbfcd7d6c2a621982e6a5da88
BLAKE2b-256 8cdf370a1e9465563261310c28104caedf966553ee2193aeb9b481ea16c75b35

See more details on using hashes here.

File details

Details for the file quicksectx-0.4.1-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: quicksectx-0.4.1-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 356.7 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.18

File hashes

Hashes for quicksectx-0.4.1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 ed13aadcf0023eef1b91141133d8b57a0aa426ca1f0a4f1ad88d4aa4d41303c5
MD5 dee1c787640682856d859cde8d0a5c60
BLAKE2b-256 bdee6f7ce5f2fd8a6caf289dc5cbcc884cf8cc4f3ae8483b8d8ab58180378e1b

See more details on using hashes here.

File details

Details for the file quicksectx-0.4.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for quicksectx-0.4.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 086e1e4e7541c2a57be23067ddbc3cb13bbd68bc9977dba7bdd4e229fdb8c04f
MD5 f55fd5e00a64640c739b0a9e4275d345
BLAKE2b-256 3d1bdf5e13e072982ebf9146e697acd5666f31abc50f920c13e3aa2019a3c561

See more details on using hashes here.

File details

Details for the file quicksectx-0.4.1-cp39-cp39-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for quicksectx-0.4.1-cp39-cp39-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 80d7bb802fcb4605bfd82a661856f250c9bbe1941c19f7e4b30ec487126c2659
MD5 525880d72a202c92b7fdbd39a7a88987
BLAKE2b-256 ee575cbfc139725df4b945237fd969f37c50aa1b7f08256f6bd8eabc8021722d

See more details on using hashes here.

File details

Details for the file quicksectx-0.4.1-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: quicksectx-0.4.1-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 357.2 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.18

File hashes

Hashes for quicksectx-0.4.1-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 d21c7e214337c40551dea0e9f6b942ac5237938234e0b85ce40121dcbd0c8390
MD5 0d70613c231702c5ffbd9d200309d288
BLAKE2b-256 108340f7ba89d40414123f3bbd059f73db343c5c988df8e46542f4d6fdb4d101

See more details on using hashes here.

File details

Details for the file quicksectx-0.4.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for quicksectx-0.4.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 21e7123982f6e33f8b25b9f0f102c80f900fba0cebfec4c14a17a81a987eb24c
MD5 96a023a2b33735f800cb0f320d011cab
BLAKE2b-256 7670c04db91cba26d257c1ebcacf0565e0cbbf7a2861336a8a7deca039e1f414

See more details on using hashes here.

File details

Details for the file quicksectx-0.4.1-cp38-cp38-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for quicksectx-0.4.1-cp38-cp38-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 60531878a5d010b2ff67d2ea648fd7e3e70ba81871388e02a588be6e290ba6b7
MD5 18ff7d7649467fa1237ea9cfeb484c5d
BLAKE2b-256 2b3cc59c57bce3a14711ce05e7a80f29f51cf03f45c191a3d12990157e253632

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page