Python库,用于不同等级的测试
py-fast-trie的Python项目详细描述
py快速试验
py fast trie是一个包含X-fast Trie和Y-fast trie的纯Python实现的包,如foundational paper所述。在
与更常见的数据结构(如二进制搜索树)相比,X-fast和Y-fast最显著的优点是搜索在宇宙基数上是对数对数的,而不是结构本身中元素数量的对数对数;作为参考,如果您需要存储2^20个潜在最大值为2^32-1的项目,则在红/黑或AVL树中查找特定项目需要20个操作,而使用X-fast或Y-fast trie只需要5个操作。在
使用
X-fast和Y-fast尝试的接口是相同的,这里以Y-fast trie为例。在
>>> 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
>>>
- 项目
标签: