Skip to main content

Python library for tries with different grades of fastness.

Project description

py-fast-trie

GitHub Workflow Codecov Python Versions Package Version

py-fast-trie is a package that contains pure-Python implementations of an X-fast Trie and a Y-fast trie, as described in the foundational paper.

The most notable benefit of X-fast and Y-fast tries compared to more common data structures such as binary search trees is that searches are log-logarithmic in the cardinality of the universe as opposed to being logarithmic in the number of elements in the structure itself; For reference if you needed to store 2^20 items with a potential maximum value of 2^32 - 1, finding a particular item would take 20 operations in a red/black or AVL tree, but only 5 with an X-fast or Y-fast trie.

Usage

The interfaces of the X-fast and Y-fast tries are identical, the Y-fast trie is used here as an example.

>>> from py_fast_trie import YFastTrie
>>> t = YFastTrie(max_length=32)		# The library defaults to the machine's word size
>>> for i in range(10, 13):
...     t += i					# Value insertion/removal operations have intuitive
>>> t.min					# shorthands
10
>>> t += b'\x0d'				# The library can handle byte strings less than the
>>> t.max					# max length by treating them as integers
13
>>> for val in t:
...     print val
10
11
12
13
>>> t < 12					# Predecessor/successor queries have intuitive
11						# shorthands
>>> t > 0
10
t -= 13
>>> t > 12
>>>

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

py-fast-trie-2.1.2.tar.gz (17.9 kB view details)

Uploaded Source

Built Distribution

py_fast_trie-2.1.2-py3-none-any.whl (12.4 kB view details)

Uploaded Python 3

File details

Details for the file py-fast-trie-2.1.2.tar.gz.

File metadata

  • Download URL: py-fast-trie-2.1.2.tar.gz
  • Upload date:
  • Size: 17.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for py-fast-trie-2.1.2.tar.gz
Algorithm Hash digest
SHA256 0fd28b709af8b322b34f747906389ae1c3da09c4b357d5ba98d70dd3bfdba03d
MD5 0e44afd26c2dcf61650d4f0f174bd294
BLAKE2b-256 4d693e9d86934ece2045653a76e54a3d1fbc9d7572679332ba57efc0024723ff

See more details on using hashes here.

File details

Details for the file py_fast_trie-2.1.2-py3-none-any.whl.

File metadata

  • Download URL: py_fast_trie-2.1.2-py3-none-any.whl
  • Upload date:
  • Size: 12.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for py_fast_trie-2.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 4a40c52908e9cf6b58a6cdb8a4b3cac0aadce8b58cd98c01198ca941a01c1a8d
MD5 633c053620508a7215009cbdc17a0bfb
BLAKE2b-256 d8fbb08e0b379896f7211a65b8e3f35f3952746709c627d989f1f8d132226fa6

See more details on using hashes here.

Supported by

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