Skip to main content

Skip list based sorted collections

Project description

Build status

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(maxsize=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. 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.2

  • Improved README

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

skiplistcollections-0.0.2.tar.gz (3.5 kB view details)

Uploaded Source

File details

Details for the file skiplistcollections-0.0.2.tar.gz.

File metadata

File hashes

Hashes for skiplistcollections-0.0.2.tar.gz
Algorithm Hash digest
SHA256 a9a2030b0552799ecd39cbdf39023e5e8bf63b6d796c0a4ecf80f0ee334d7d8e
MD5 863ce5d29f357720b7c18ded764c7667
BLAKE2b-256 54f10ab2338275d9f62c9c430b42ede95d4e08b6691eeb6acbaa7bac80911998

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