Skip list based sorted collections
Project description
skiplistcollections is a Python module containing skip list based sorted collections. skiplistcollections is written in Python and works with:
CPython 2.6+, 3.2+
PyPy 1.9+
Project page on GitHub: https://github.com/jstasiak/skiplistcollections
Project page on PyPI: https://pypi.python.org/pypi/skiplistcollections
Usage
See http://pythonsweetness.tumblr.com/post/45227295342/fast-pypy-compatible-ordered-map-in-89-lines-of-python for details.
>>> from skiplistcollections import SkipListDict
>>> things = SkipListDict(capacity=16)
>>> len(things)
0
>>> things['x'] = 1
>>> 'x' in things
True
>>> len(things)
1
>>> things['g'] = 2
>>> things['z'] = 3
>>> tuple(things.keys())
('g', 'x', 'z')
>>> tuple(things.values())
(2, 1, 3)
>>> tuple(things.items())
(('g', 2), ('x', 1), ('z', 3))
>>> del things['z']
>>> len(things)
2
As you can see, skipcollections.SkipListDict follows Python dict interface quite closely. In fact it inherits MutableMapping Abstract Base Class. You should note that:
You need to set the maximum dict size when you create it
update method and initializing using another mapping are not supported yet
On Python 2 there are items/keys/values (returning tuples) and iteritems/iterkeys/itervalues (returning generators) methods, on Python 3 there are only items/keys/values and they return generators (it should be probably changed to return views for the sake of compatibility)
Changes
0.0.3
items(), values(), keys() return views now
0.0.2
Improved README
Copyright
Original version - Copyright (C) 2013 David Wilson
Copyright (C) 2013 Jakub Stasiak
This source code is licensed under MIT license, see LICENSE file for details.
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
Built Distribution
Hashes for skiplistcollections-0.0.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | f7e9981c94e54fac70ef006384dc4ad0eb0ab80cdb7026759247973f55c450e3 |
|
MD5 | 6ae603123bac77126fb3cfa3daafa158 |
|
BLAKE2b-256 | dfe4ce67f1fbfba0336637f3729b26086637f88be853f5b41225b50309019cfd |
Hashes for skiplistcollections-0.0.3-py27-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 15fdfb5f7be3ce1c452981b9a2471dab4b84cb671817d53e74cbf2b1ae8ddedb |
|
MD5 | 10e489e83aad928cf247bf3f9597dbe3 |
|
BLAKE2b-256 | 621c80ab03dab9dec08b3b6e13ec817f5fa72a440a2656df4c96eb6ab2ac89a7 |