pyredblack
Copyright (c) 2015 Will Roberts <wildwilhelm@gmail.com>
Licensed under the MIT License (see LICENSE.rst for details).
Cython interface to red-black trees implemented in C++.
Red-black trees are a kind of self-balancing binary tree. They maintain their entries in sorted order and have O(log n) for insertion, lookup, and deletion. You can read more about red-black trees and see animations of insertion, lookup, and deletion.
This package provides dictionary and set objects based on red-black-trees; these can be used as drop-in replacements for the built-in dict and set types, except that they maintain their contents in sorted order.
Dictionary (rbdict):
>>> import pyredblack
>>> d = pyredblack.rbdict(Germany = 'Berlin',
Hungary = 'Budapest',
Ireland = 'Dublin',
Portugal = 'Lisbon',
Cyprus = 'Nicosia',
Greenland = 'Nuuk',
Iceland = 'Reykjavik',
Macedonia = 'Skopje',
Bulgaria = 'Sofia',
Sweden = 'Stockholm')
>>> len(d)
10
>>> d['Ireland']
'Dublin'
>>> d.keys()
['Bulgaria', 'Cyprus', 'Germany', 'Greenland', 'Hungary',
'Iceland', 'Ireland', 'Macedonia', 'Portugal', 'Sweden']
>>> d.values()
['Sofia', 'Nicosia', 'Berlin', 'Nuuk', 'Budapest',
'Reykjavik', 'Dublin', 'Skopje', 'Lisbon', 'Stockholm']
>>> d.popitem()
('Bulgaria', 'Sofia')
>>> d.popitem()
('Cyprus', 'Nicosia')
>>> d.popitem()
('Germany', 'Berlin')
Set (rbset):
>>> fruit = pyredblack.rbset(['apple', 'orange', 'apple', 'pear',
'orange', 'banana'])
>>> 'orange' in fruit
True
>>> 'crabgrass' in fruit
False
>>> a = pyredblack.rbset('abracadabra')
>>> b = pyredblack.rbset('alacazam')
>>> list(a)
['a', 'b', 'c', 'd', 'r']
>>> list(a - b)
['b', 'd', 'r']
>>> list(a | b)
['a', 'b', 'c', 'd', 'l', 'm', 'r', 'z']
>>> list(a & b)
['a', 'c']
>>> list(a ^ b)
['b', 'd', 'l', 'm', 'r', 'z']
>>> a.pop()
'a'
>>> a.pop()
'b'
>>> a.pop()
'c'
Requirements
Python 2.7, Python 3.2+
Cython (and a C++ compiler)
Todo
implement slicing on dictionaries
Metadata
Release files for pyredblack 0.1.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 | |
|---|---|---|---|
| pyredblack-0.1.1.tar.gz | 88.7 kB | Details |
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pyredblack-0.1.1-cp35-cp35m-macosx_10_11_x86_64.whl | CPython 3.5 | CPython 3.5 pymalloc | macOS 10.11+ x86-64 | Details |
| pyredblack-0.1.1-cp34-cp34m-macosx_10_11_x86_64.whl | CPython 3.4 | CPython 3.4 pymalloc | macOS 10.11+ x86-64 | Details |
| pyredblack-0.1.1-cp27-none-macosx_10_11_x86_64.whl | CPython 2.7 | none | macOS 10.11+ x86-64 | Details |
Total release size: 340.1 kB
Release files / pyredblack-0.1.1.tar.gz
| Download URL | pyredblack-0.1.1.tar.gz |
|---|---|
| Size | 88.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
de4b67ca1e62d783a862bef1c594dcda088d1f309a762d5408a803c8f70c3603
|
|
BLAKE2b-256 checksum How to use checksums |
e19e6779fafd66df75cf5b1881929db7626f09717fb4900a7a5aeb200b134b34
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / pyredblack-0.1.1-cp35-cp35m-macosx_10_11_x86_64.whl
| Download URL | pyredblack-0.1.1-cp35-cp35m-macosx_10_11_x86_64.whl |
|---|---|
| Size | 83.6 kB |
| Tags | CPython 3.5 CPython 3.5 pymalloc macOS 10.11+ x86-64 |
|
SHA-256 checksum How to use checksums |
d1935966d13b91c1fc9ebdb434bc2d4c66f6ac3b4e4d74d4eb80e20c7b17118a
|
|
BLAKE2b-256 checksum How to use checksums |
85ea4b43a2869cf41ed529e96e524828a26d13f1b85a11690e1c73c259779723
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / pyredblack-0.1.1-cp34-cp34m-macosx_10_11_x86_64.whl
| Download URL | pyredblack-0.1.1-cp34-cp34m-macosx_10_11_x86_64.whl |
|---|---|
| Size | 83.8 kB |
| Tags | CPython 3.4 CPython 3.4 pymalloc macOS 10.11+ x86-64 |
|
SHA-256 checksum How to use checksums |
8a4ff3b951b0872d01ce2d05943a60a311e063e38d81d0699a6475eadf2a316b
|
|
BLAKE2b-256 checksum How to use checksums |
d8c7e2ad5b3bd972455720b499fbea534e3fbb779d7ab9560801fda91cadbda0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / pyredblack-0.1.1-cp27-none-macosx_10_11_x86_64.whl
| Download URL | pyredblack-0.1.1-cp27-none-macosx_10_11_x86_64.whl |
|---|---|
| Size | 84.0 kB |
| Tags | CPython 2.7 macOS 10.11+ x86-64 |
|
SHA-256 checksum How to use checksums |
141040cbb8d06f0737b9fa9766064099688adb8e09bb7bb3fd8af2865eb2e613
|
|
BLAKE2b-256 checksum How to use checksums |
379481032a0f9efce24ab7c30a40255ce0fec055f22c454b640d7c60d469db1f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |