{ "info": { "author": "Tin Tvrtkovic", "author_email": "tin.tvrtkovic@nanobit.co", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "Programming Language :: Python :: 3.5" ], "description": "rangetree: easy range lookups\n=============================\n\n.. image:: https://img.shields.io/pypi/v/rangetree.svg\n :target: https://pypi.python.org/pypi/rangetree\n.. image:: https://travis-ci.org/nanobit/rangetree.svg?branch=master\n :target: https://travis-ci.org/nanobit/rangetree\n.. image:: https://coveralls.io/repos/github/nanobit/rangetree/badge.svg?branch=master\n :target: https://coveralls.io/github/nanobit/rangetree?branch=master\n\n``rangetree`` is an Apache2 licensed library, written in Python 3, for easy and fast\nlookups of numeric ranges.\n\nGiven three integer ranges, 0 - 9, 10 - 99, and 100 - 999, ``rangetree`` makes\nit trivial to look up exactly which range any integer falls in. (Note Python\nslices and ranges include the first index, and exclude the second.)\n\n.. code-block:: python\n\n >>> from rangetree import RangeTree\n >>>\n >>> r = RangeTree()\n >>> r[0:10] = 'single digits'\n >>> r[10:100] = 'double digits'\n >>> r[100:1000] = 'triple digits'\n >>>\n >>> r[4]\n 'single digits'\n\n\n``RangeTree`` s are optimized for lookups, and make use of the excellent\nbintrees library.\n\n.. _bintrees: https://bitbucket.org/mozman/bintrees\n\nFeatures\n--------\n\n- supports open and closed ranges\n- supports integer keys\n- optimized for lookups (not insertions)\n\nInstallation\n------------\n\nTo install ``rangetree``, simply:\n\n.. code-block:: bash\n\n $ pip install rangetree\n\nUsage\n-----\n\nInsertion is done using Python's slice notation, or using range objects.\n\n.. code-block:: python\n\n >>> r = RangeTree()\n >>> r[0:10] = 'single digits'\n >>> r[range(10, 100)] = 'double digits'\n\nNegative integers are supported.\n\n.. code-block:: python\n\n >>> r[-10:0] = 'negative singles'\n\nMissing a range will result in a ``KeyError``. Use ``Rangetree.get()`` or\nthe ``in`` operator.\n\n.. code-block:: python\n\n >>> 1000 in r\n False\n >>> r[1000]\n Traceback (most recent call last):\n File \"\", line 1, in \n File \"rangetree.py\", line 93, in __getitem__\n raise KeyError(key)\n KeyError: 1000\n >>> r.get(1000, 'no value')\n 'no value'\n\nOpen ranges (that go to or from infinity) are supported. Setting open ranges is only\npossible using the slice notation.\n\n.. code-block:: python\n\n >>> r[1000:] = 'quadruple digits or more'\n >>> r[999999999]\n 'quadruple digits or more'\n\nOverlapping ranges will result in a ``KeyError``.\n\n.. code-block:: python\n\n >>> r = RangeTree()\n >>> r[1000:] = 'quadruple digits or more'\n >>> r[10000:] = 'ten thousand'\n Traceback (most recent call last):\n File \"\", line 1, in \n File \"rangetree.py\", line 58, in __setitem__\n raise KeyError('Overlapping intervals.')\n KeyError: 'Overlapping intervals.'\n\n``rangetree`` is fast. Using ``perf``, given 2000 intervals:\n\n.. code-block:: bash\n\n $ pyperf timeit --rigorous -g --duplicate 5 -s \"from rangetree import RangeTree; r = RangeTree()\" -s \"for i in range(2000):\" -s \" r[i*10:i*10+10] = i\" \"r[500]\"\n .........................................\n 3.75 us: 1 #######\n 3.77 us: 2 #############\n 3.80 us: 9 ###########################################################\n 3.82 us: 5 #################################\n 3.84 us: 8 #####################################################\n 3.86 us: 9 ###########################################################\n 3.89 us: 7 ##############################################\n 3.91 us: 8 #####################################################\n 3.93 us: 8 #####################################################\n 3.95 us: 6 ########################################\n 3.98 us: 10 ##################################################################\n 4.00 us: 12 ###############################################################################\n 4.02 us: 5 #################################\n 4.05 us: 9 ###########################################################\n 4.07 us: 5 #################################\n 4.09 us: 6 ########################################\n 4.11 us: 3 ####################\n 4.14 us: 4 ##########################\n 4.16 us: 2 #############\n 4.18 us: 0 |\n 4.20 us: 1 #######\n\n Median +- std dev: 3.97 us +- 0.11 us\n\nThe ballpark figure for lookups is in the single digit microseconds.\n\nChangelog\n---------\n\n1.0 (2016-10-20)\n~~~~~~~~~~~~~~~~~~\nInitial public release.\n\n\nContributing\n------------\nContributions are very welcome. Tests can be run with ``tox``, please ensure\nthe coverage at least stays the same before you submit a pull request.\n\nCredits\n-------\n\nThe development of ``rangetree`` is sponsored by Nanobit_.\n\n``rangetree`` is tested with Hypothesis_, by David R. MacIver.\n\n``rangetree`` is benchmarked using perf_, by Victor Stinner.\n\n.. _Nanobit: http://nanobit.co\n.. _Hypothesis: http://hypothesis.readthedocs.io/en/latest/\n.. _perf: https://github.com/haypo/perf", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/nanobit/rangetree", "keywords": null, "license": "Apache 2.0", "maintainer": null, "maintainer_email": null, "name": "rangetree", "package_url": "https://pypi.org/project/rangetree/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/rangetree/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/nanobit/rangetree" }, "release_url": "https://pypi.org/project/rangetree/1.0/", "requires_dist": null, "requires_python": null, "summary": "Quick lookups of values in numeric ranges.", "version": "1.0" }, "last_serial": 2463825, "releases": { "1.0": [ { "comment_text": "", "digests": { "md5": "12b946f010bae79f0d2e715c8cfcc1de", "sha256": "eea7a01fc2785d9b5da93e39b0e3bba6689d62ff910ae721c14ac2039f2fb0e2" }, "downloads": -1, "filename": "rangetree-1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "12b946f010bae79f0d2e715c8cfcc1de", "packagetype": "bdist_wheel", "python_version": "3.5", "requires_python": null, "size": 6531, "upload_time": "2016-11-16T10:09:50", "url": "https://files.pythonhosted.org/packages/f1/85/257b0d60c3e779d2a2d78e67edbf42e81a627178958484a5a423107f2aaf/rangetree-1.0-py3-none-any.whl" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "12b946f010bae79f0d2e715c8cfcc1de", "sha256": "eea7a01fc2785d9b5da93e39b0e3bba6689d62ff910ae721c14ac2039f2fb0e2" }, "downloads": -1, "filename": "rangetree-1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "12b946f010bae79f0d2e715c8cfcc1de", "packagetype": "bdist_wheel", "python_version": "3.5", "requires_python": null, "size": 6531, "upload_time": "2016-11-16T10:09:50", "url": "https://files.pythonhosted.org/packages/f1/85/257b0d60c3e779d2a2d78e67edbf42e81a627178958484a5a423107f2aaf/rangetree-1.0-py3-none-any.whl" } ] }