[Python-modules-commits] [sortedcontainers] 01/02: Imported Upstream version 0.9.6
Sandro Tosi
morph at moszumanska.debian.org
Mon Jun 29 22:27:39 UTC 2015
This is an automated email from the git hooks/post-receive script.
morph pushed a commit to branch master
in repository sortedcontainers.
commit 3734cda7ca539c7a5c770c8d0d4f49254d09915d
Author: Sandro Tosi <morph at debian.org>
Date: Mon Jun 29 18:28:25 2015 -0400
Imported Upstream version 0.9.6
---
LICENSE | 13 +
MANIFEST.in | 1 +
PKG-INFO | 238 ++++
README.rst | 202 ++++
setup.cfg | 5 +
setup.py | 52 +
sortedcontainers.egg-info/PKG-INFO | 238 ++++
sortedcontainers.egg-info/SOURCES.txt | 13 +
sortedcontainers.egg-info/dependency_links.txt | 1 +
sortedcontainers.egg-info/top_level.txt | 1 +
sortedcontainers/__init__.py | 55 +
sortedcontainers/sorteddict.py | 718 +++++++++++
sortedcontainers/sortedlist.py | 1374 +++++++++++++++++++++
sortedcontainers/sortedlistwithkey.py | 1511 ++++++++++++++++++++++++
sortedcontainers/sortedset.py | 302 +++++
15 files changed, 4724 insertions(+)
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..76f1ed3
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,13 @@
+Copyright 2014 Grant Jenks
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/MANIFEST.in b/MANIFEST.in
new file mode 100644
index 0000000..0c73842
--- /dev/null
+++ b/MANIFEST.in
@@ -0,0 +1 @@
+include README.rst LICENSE
diff --git a/PKG-INFO b/PKG-INFO
new file mode 100644
index 0000000..f1529a8
--- /dev/null
+++ b/PKG-INFO
@@ -0,0 +1,238 @@
+Metadata-Version: 1.1
+Name: sortedcontainers
+Version: 0.9.6
+Summary: Python Sorted Container Types: SortedList, SortedDict, and SortedSet
+Home-page: http://www.grantjenks.com/docs/sortedcontainers/
+Author: Grant Jenks
+Author-email: contact at grantjenks.com
+License: Copyright 2014 Grant Jenks
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+Description: SortedContainers
+ ================
+
+ .. image:: https://api.travis-ci.org/grantjenks/sorted_containers.svg
+ :target: http://www.grantjenks.com/docs/sortedcontainers/
+
+ SortedContainers is an Apache2 licensed containers library, written in
+ pure-Python, and fast as C-extensions.
+
+ Python's standard library is great until you need a sorted container type. Many
+ will attest that you can get really far without one, but the moment you **really
+ need** a sorted list, dict, or set, you're faced with a dozen different
+ implementations, most using C-extensions without great documentation and
+ benchmarking.
+
+ Things shouldn't be this way. Not in Python.
+
+ ::
+
+ >>> sl = sortedcontainers.SortedList(xrange(10000000))
+ >>> 1234567 in sl
+ True
+ >>> sl[7654321]
+ 7654321
+ >>> sl.add(1234567)
+ >>> sl.count(1234567)
+ 2
+ >>> sl *= 3
+ >>> len(sl)
+ 30000003
+
+ **Note:** don't try this at home without at least a gigabyte of memory. In
+ Python an integer requires at least 12 bytes. SortedList will add about 4
+ bytes per object stored in the container. That's pretty hard to beat as it's
+ the cost of a pointer to each object. It's also 66% less overhead than a
+ typical binary tree implementation (e.g. red-black tree, avl tree, aa tree,
+ splay tree, treap, etc.) for which every node must also store two pointers to
+ children nodes.
+
+ SortedContainers takes all of the work out of Python sorted types - making your
+ deployment and use of Python easy. There's no need to install a C compiler or
+ pre-build and distribute custom extensions. Performance is a feature and testing
+ has 100% coverage with unit tests and hours of stress.
+
+ Testimonials
+ ------------
+
+ **Alex Martelli**, `Wikipedia`_
+
+ Good stuff! ... I like the `simple, effective implementation`_ idea of splitting
+ the sorted containers into smaller "fragments" to avoid the O(N) insertion costs.
+
+ .. _`Wikipedia`: http://en.wikipedia.org/wiki/Alex_Martelli
+ .. _`simple, effective implementation`: http://www.grantjenks.com/docs/sortedcontainers/implementation.html
+
+ **Jeff Knupp**, `Review of SortedContainers`_
+
+ That last part, "fast as C-extensions," was difficult to believe. I would need
+ some sort of `performance comparison`_ to be convinced this is true. The author
+ includes this in the docs. It is.
+
+ .. _`Review of SortedContainers`: http://reviews.jeffknupp.com/reviews/sortedcontainers/3/
+ .. _`performance comparison`: http://www.grantjenks.com/docs/sortedcontainers/performance.html
+
+ **Kevin Samuel**, `Formations Python`_
+
+ I'm quite amazed, not just by the code quality (it's incredibly
+ readable and has more comment than code, wow), but the actual
+ amount of work you put at stuff that is *not* code:
+ documentation, benchmarking, implementation explanations. Even
+ the git log is clean and the unit tests run out of the box on
+ Python 2 and 3.
+
+ .. _`Formations Python`: http://formationspython.com/
+
+ **Mark Summerfield**, a short plea for `Python Sorted Collections`_
+
+ Python's "batteries included" standard library seems to have a battery
+ missing. And the argument that "we never had it before" has worn thin. It is
+ time that Python offered a full range of collection classes out of the box,
+ including sorted ones.
+
+ .. _`Python Sorted Collections`: http://www.qtrac.eu/pysorted.html
+
+ Features
+ --------
+
+ - Pure-Python
+ - Fully documented
+ - Benchmark comparison (alternatives, runtimes, load-factors)
+ - 100% test coverage
+ - Hours of stress testing
+ - Performance matters (often faster than C implementations)
+ - Compatible API (nearly identical to popular blist and rbtree modules)
+ - Feature-rich (e.g. get the five largest keys in a sorted dict: d.iloc[-5:])
+ - Pragmatic design (e.g. SortedSet is a Python set with a SortedList index)
+ - Developed on Python 2.7
+ - Tested on CPython 2.6, 2.7, 3.2, 3.3, 3.4 and PyPy 2.2+, PyPy3 2.3.1+
+
+ Quickstart
+ ----------
+
+ Installing SortedContainers is simple with
+ `pip <http://www.pip-installer.org/>`_::
+
+ > pip install sortedcontainers
+
+ You can access documentation in the interpreter with Python's built-in help
+ function:
+
+ ::
+
+ >>> from sortedcontainers import SortedList, SortedSet, SortedDict
+ >>> help(SortedList)
+
+ Documentation
+ -------------
+
+ Complete documentation including performance comparisons is available at
+ http://www.grantjenks.com/docs/sortedcontainers/ .
+
+ User Guide
+ ..........
+
+ For those wanting more details, this part of the documentation describes
+ introduction, implementation, performance, and development.
+
+ - `Introduction`_
+ - `Performance Comparison`_
+ - `Load Factor Performance Comparison`_
+ - `Runtime Performance Comparison`_
+ - `Simulated Workload Performance Comparison`_
+ - `Implementation Details`_
+ - `Developing and Contributing`_
+
+ .. _`Introduction`: http://www.grantjenks.com/docs/sortedcontainers/introduction.html
+ .. _`Performance Comparison`: http://www.grantjenks.com/docs/sortedcontainers/performance.html
+ .. _`Load Factor Performance Comparison`: http://www.grantjenks.com/docs/sortedcontainers/performance-load.html
+ .. _`Runtime Performance Comparison`: http://www.grantjenks.com/docs/sortedcontainers/performance-runtime.html
+ .. _`Simulated Workload Performance Comparison`: http://www.grantjenks.com/docs/sortedcontainers/performance-workload.html
+ .. _`Implementation Details`: http://www.grantjenks.com/docs/sortedcontainers/implementation.html
+ .. _`Developing and Contributing`: http://www.grantjenks.com/docs/sortedcontainers/development.html
+
+ API Documentation
+ .................
+
+ If you are looking for information on a specific function, class or method, this
+ part of the documentation is for you.
+
+ - `SortedList`_
+ - `SortedListWithKey`_
+ - `SortedDict`_
+ - `SortedSet`_
+
+ .. _`SortedList`: http://www.grantjenks.com/docs/sortedcontainers/sortedlist.html
+ .. _`SortedListWithKey`: http://www.grantjenks.com/docs/sortedcontainers/sortedlistwithkey.html
+ .. _`SortedDict`: http://www.grantjenks.com/docs/sortedcontainers/sorteddict.html
+ .. _`SortedSet`: http://www.grantjenks.com/docs/sortedcontainers/sortedset.html
+
+ Contribute
+ ----------
+
+ Collaborators are welcome!
+
+ #. Check for open issues or open a fresh issue to start a discussion around a
+ bug. There is a Contributor Friendly tag for issues that should be used by
+ people who are not very familiar with the codebase yet.
+ #. Fork `the repository <https://github.com/grantjenks/sorted_containers>`_ on
+ GitHub and start making your changes to a new branch.
+ #. Write a test which shows that the bug was fixed.
+ #. Send a pull request and bug the maintainer until it gets merged and
+ published. :)
+
+ Useful Links
+ ------------
+
+ - `SortedContainers Project @ GrantJenks.com`_
+ - `SortedContainers @ PyPI`_
+ - `SortedContainers @ Github`_
+ - `Issue Tracker`_
+
+ .. _`SortedContainers Project @ GrantJenks.com`: http://www.grantjenks.com/docs/sortedcontainers/
+ .. _`SortedContainers @ PyPI`: https://pypi.python.org/pypi/sortedcontainers
+ .. _`SortedContainers @ Github`: https://github.com/grantjenks/sorted_containers
+ .. _`Issue Tracker`: https://github.com/grantjenks/sorted_containers/issues
+
+ SortedContainers License
+ ------------------------
+
+ Copyright 2015 Grant Jenks
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+Platform: UNKNOWN
+Classifier: Development Status :: 4 - Beta
+Classifier: Intended Audience :: Developers
+Classifier: Natural Language :: English
+Classifier: License :: OSI Approved :: Apache Software License
+Classifier: Programming Language :: Python
+Classifier: Programming Language :: Python :: Implementation :: CPython
+Classifier: Programming Language :: Python :: Implementation :: PyPy
+Classifier: Programming Language :: Python :: 2.6
+Classifier: Programming Language :: Python :: 2.7
+Classifier: Programming Language :: Python :: 3
+Classifier: Programming Language :: Python :: 3.2
+Classifier: Programming Language :: Python :: 3.3
+Classifier: Programming Language :: Python :: 3.4
diff --git a/README.rst b/README.rst
new file mode 100644
index 0000000..ea96011
--- /dev/null
+++ b/README.rst
@@ -0,0 +1,202 @@
+SortedContainers
+================
+
+.. image:: https://api.travis-ci.org/grantjenks/sorted_containers.svg
+ :target: http://www.grantjenks.com/docs/sortedcontainers/
+
+SortedContainers is an Apache2 licensed containers library, written in
+pure-Python, and fast as C-extensions.
+
+Python's standard library is great until you need a sorted container type. Many
+will attest that you can get really far without one, but the moment you **really
+need** a sorted list, dict, or set, you're faced with a dozen different
+implementations, most using C-extensions without great documentation and
+benchmarking.
+
+Things shouldn't be this way. Not in Python.
+
+::
+
+ >>> sl = sortedcontainers.SortedList(xrange(10000000))
+ >>> 1234567 in sl
+ True
+ >>> sl[7654321]
+ 7654321
+ >>> sl.add(1234567)
+ >>> sl.count(1234567)
+ 2
+ >>> sl *= 3
+ >>> len(sl)
+ 30000003
+
+**Note:** don't try this at home without at least a gigabyte of memory. In
+Python an integer requires at least 12 bytes. SortedList will add about 4
+bytes per object stored in the container. That's pretty hard to beat as it's
+the cost of a pointer to each object. It's also 66% less overhead than a
+typical binary tree implementation (e.g. red-black tree, avl tree, aa tree,
+splay tree, treap, etc.) for which every node must also store two pointers to
+children nodes.
+
+SortedContainers takes all of the work out of Python sorted types - making your
+deployment and use of Python easy. There's no need to install a C compiler or
+pre-build and distribute custom extensions. Performance is a feature and testing
+has 100% coverage with unit tests and hours of stress.
+
+Testimonials
+------------
+
+**Alex Martelli**, `Wikipedia`_
+
+Good stuff! ... I like the `simple, effective implementation`_ idea of splitting
+the sorted containers into smaller "fragments" to avoid the O(N) insertion costs.
+
+.. _`Wikipedia`: http://en.wikipedia.org/wiki/Alex_Martelli
+.. _`simple, effective implementation`: http://www.grantjenks.com/docs/sortedcontainers/implementation.html
+
+**Jeff Knupp**, `Review of SortedContainers`_
+
+That last part, "fast as C-extensions," was difficult to believe. I would need
+some sort of `performance comparison`_ to be convinced this is true. The author
+includes this in the docs. It is.
+
+.. _`Review of SortedContainers`: http://reviews.jeffknupp.com/reviews/sortedcontainers/3/
+.. _`performance comparison`: http://www.grantjenks.com/docs/sortedcontainers/performance.html
+
+**Kevin Samuel**, `Formations Python`_
+
+I'm quite amazed, not just by the code quality (it's incredibly
+readable and has more comment than code, wow), but the actual
+amount of work you put at stuff that is *not* code:
+documentation, benchmarking, implementation explanations. Even
+the git log is clean and the unit tests run out of the box on
+Python 2 and 3.
+
+.. _`Formations Python`: http://formationspython.com/
+
+**Mark Summerfield**, a short plea for `Python Sorted Collections`_
+
+Python's "batteries included" standard library seems to have a battery
+missing. And the argument that "we never had it before" has worn thin. It is
+time that Python offered a full range of collection classes out of the box,
+including sorted ones.
+
+.. _`Python Sorted Collections`: http://www.qtrac.eu/pysorted.html
+
+Features
+--------
+
+- Pure-Python
+- Fully documented
+- Benchmark comparison (alternatives, runtimes, load-factors)
+- 100% test coverage
+- Hours of stress testing
+- Performance matters (often faster than C implementations)
+- Compatible API (nearly identical to popular blist and rbtree modules)
+- Feature-rich (e.g. get the five largest keys in a sorted dict: d.iloc[-5:])
+- Pragmatic design (e.g. SortedSet is a Python set with a SortedList index)
+- Developed on Python 2.7
+- Tested on CPython 2.6, 2.7, 3.2, 3.3, 3.4 and PyPy 2.2+, PyPy3 2.3.1+
+
+Quickstart
+----------
+
+Installing SortedContainers is simple with
+`pip <http://www.pip-installer.org/>`_::
+
+ > pip install sortedcontainers
+
+You can access documentation in the interpreter with Python's built-in help
+function:
+
+::
+
+ >>> from sortedcontainers import SortedList, SortedSet, SortedDict
+ >>> help(SortedList)
+
+Documentation
+-------------
+
+Complete documentation including performance comparisons is available at
+http://www.grantjenks.com/docs/sortedcontainers/ .
+
+User Guide
+..........
+
+For those wanting more details, this part of the documentation describes
+introduction, implementation, performance, and development.
+
+- `Introduction`_
+- `Performance Comparison`_
+- `Load Factor Performance Comparison`_
+- `Runtime Performance Comparison`_
+- `Simulated Workload Performance Comparison`_
+- `Implementation Details`_
+- `Developing and Contributing`_
+
+.. _`Introduction`: http://www.grantjenks.com/docs/sortedcontainers/introduction.html
+.. _`Performance Comparison`: http://www.grantjenks.com/docs/sortedcontainers/performance.html
+.. _`Load Factor Performance Comparison`: http://www.grantjenks.com/docs/sortedcontainers/performance-load.html
+.. _`Runtime Performance Comparison`: http://www.grantjenks.com/docs/sortedcontainers/performance-runtime.html
+.. _`Simulated Workload Performance Comparison`: http://www.grantjenks.com/docs/sortedcontainers/performance-workload.html
+.. _`Implementation Details`: http://www.grantjenks.com/docs/sortedcontainers/implementation.html
+.. _`Developing and Contributing`: http://www.grantjenks.com/docs/sortedcontainers/development.html
+
+API Documentation
+.................
+
+If you are looking for information on a specific function, class or method, this
+part of the documentation is for you.
+
+- `SortedList`_
+- `SortedListWithKey`_
+- `SortedDict`_
+- `SortedSet`_
+
+.. _`SortedList`: http://www.grantjenks.com/docs/sortedcontainers/sortedlist.html
+.. _`SortedListWithKey`: http://www.grantjenks.com/docs/sortedcontainers/sortedlistwithkey.html
+.. _`SortedDict`: http://www.grantjenks.com/docs/sortedcontainers/sorteddict.html
+.. _`SortedSet`: http://www.grantjenks.com/docs/sortedcontainers/sortedset.html
+
+Contribute
+----------
+
+Collaborators are welcome!
+
+#. Check for open issues or open a fresh issue to start a discussion around a
+ bug. There is a Contributor Friendly tag for issues that should be used by
+ people who are not very familiar with the codebase yet.
+#. Fork `the repository <https://github.com/grantjenks/sorted_containers>`_ on
+ GitHub and start making your changes to a new branch.
+#. Write a test which shows that the bug was fixed.
+#. Send a pull request and bug the maintainer until it gets merged and
+ published. :)
+
+Useful Links
+------------
+
+- `SortedContainers Project @ GrantJenks.com`_
+- `SortedContainers @ PyPI`_
+- `SortedContainers @ Github`_
+- `Issue Tracker`_
+
+.. _`SortedContainers Project @ GrantJenks.com`: http://www.grantjenks.com/docs/sortedcontainers/
+.. _`SortedContainers @ PyPI`: https://pypi.python.org/pypi/sortedcontainers
+.. _`SortedContainers @ Github`: https://github.com/grantjenks/sorted_containers
+.. _`Issue Tracker`: https://github.com/grantjenks/sorted_containers/issues
+
+SortedContainers License
+------------------------
+
+Copyright 2015 Grant Jenks
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/setup.cfg b/setup.cfg
new file mode 100644
index 0000000..861a9f5
--- /dev/null
+++ b/setup.cfg
@@ -0,0 +1,5 @@
+[egg_info]
+tag_build =
+tag_date = 0
+tag_svn_revision = 0
+
diff --git a/setup.py b/setup.py
new file mode 100644
index 0000000..50b0f14
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,52 @@
+# -*- coding: utf-8 -*-
+
+import sys
+from setuptools import setup, find_packages
+from setuptools.command.test import test as TestCommand
+
+import sortedcontainers
+
+class Tox(TestCommand):
+ def finalize_options(self):
+ TestCommand.finalize_options(self)
+ self.test_args = []
+ self.test_suite = True
+ def run_tests(self):
+ import tox
+ errno = tox.cmdline(self.test_args)
+ sys.exit(errno)
+
+with open('README.rst') as fptr:
+ readme = fptr.read()
+
+with open('LICENSE') as fptr:
+ license = fptr.read()
+
+setup(
+ name=sortedcontainers.__title__,
+ version=sortedcontainers.__version__,
+ description='Python Sorted Container Types: SortedList, SortedDict, and SortedSet',
+ long_description=readme,
+ author='Grant Jenks',
+ author_email='contact at grantjenks.com',
+ url='http://www.grantjenks.com/docs/sortedcontainers/',
+ license=license,
+ packages=find_packages(exclude=('tests', 'docs')),
+ tests_require=['tox'],
+ cmdclass={'test': Tox},
+ classifiers=(
+ 'Development Status :: 4 - Beta',
+ 'Intended Audience :: Developers',
+ 'Natural Language :: English',
+ 'License :: OSI Approved :: Apache Software License',
+ 'Programming Language :: Python',
+ 'Programming Language :: Python :: Implementation :: CPython',
+ 'Programming Language :: Python :: Implementation :: PyPy',
+ 'Programming Language :: Python :: 2.6',
+ 'Programming Language :: Python :: 2.7',
+ 'Programming Language :: Python :: 3',
+ 'Programming Language :: Python :: 3.2',
+ 'Programming Language :: Python :: 3.3',
+ 'Programming Language :: Python :: 3.4',
+ ),
+)
diff --git a/sortedcontainers.egg-info/PKG-INFO b/sortedcontainers.egg-info/PKG-INFO
new file mode 100644
index 0000000..f1529a8
--- /dev/null
+++ b/sortedcontainers.egg-info/PKG-INFO
@@ -0,0 +1,238 @@
+Metadata-Version: 1.1
+Name: sortedcontainers
+Version: 0.9.6
+Summary: Python Sorted Container Types: SortedList, SortedDict, and SortedSet
+Home-page: http://www.grantjenks.com/docs/sortedcontainers/
+Author: Grant Jenks
+Author-email: contact at grantjenks.com
+License: Copyright 2014 Grant Jenks
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+Description: SortedContainers
+ ================
+
+ .. image:: https://api.travis-ci.org/grantjenks/sorted_containers.svg
+ :target: http://www.grantjenks.com/docs/sortedcontainers/
+
+ SortedContainers is an Apache2 licensed containers library, written in
+ pure-Python, and fast as C-extensions.
+
+ Python's standard library is great until you need a sorted container type. Many
+ will attest that you can get really far without one, but the moment you **really
+ need** a sorted list, dict, or set, you're faced with a dozen different
+ implementations, most using C-extensions without great documentation and
+ benchmarking.
+
+ Things shouldn't be this way. Not in Python.
+
+ ::
+
+ >>> sl = sortedcontainers.SortedList(xrange(10000000))
+ >>> 1234567 in sl
+ True
+ >>> sl[7654321]
+ 7654321
+ >>> sl.add(1234567)
+ >>> sl.count(1234567)
+ 2
+ >>> sl *= 3
+ >>> len(sl)
+ 30000003
+
+ **Note:** don't try this at home without at least a gigabyte of memory. In
+ Python an integer requires at least 12 bytes. SortedList will add about 4
+ bytes per object stored in the container. That's pretty hard to beat as it's
+ the cost of a pointer to each object. It's also 66% less overhead than a
+ typical binary tree implementation (e.g. red-black tree, avl tree, aa tree,
+ splay tree, treap, etc.) for which every node must also store two pointers to
+ children nodes.
+
+ SortedContainers takes all of the work out of Python sorted types - making your
+ deployment and use of Python easy. There's no need to install a C compiler or
+ pre-build and distribute custom extensions. Performance is a feature and testing
+ has 100% coverage with unit tests and hours of stress.
+
+ Testimonials
+ ------------
+
+ **Alex Martelli**, `Wikipedia`_
+
+ Good stuff! ... I like the `simple, effective implementation`_ idea of splitting
+ the sorted containers into smaller "fragments" to avoid the O(N) insertion costs.
+
+ .. _`Wikipedia`: http://en.wikipedia.org/wiki/Alex_Martelli
+ .. _`simple, effective implementation`: http://www.grantjenks.com/docs/sortedcontainers/implementation.html
+
+ **Jeff Knupp**, `Review of SortedContainers`_
+
+ That last part, "fast as C-extensions," was difficult to believe. I would need
+ some sort of `performance comparison`_ to be convinced this is true. The author
+ includes this in the docs. It is.
+
+ .. _`Review of SortedContainers`: http://reviews.jeffknupp.com/reviews/sortedcontainers/3/
+ .. _`performance comparison`: http://www.grantjenks.com/docs/sortedcontainers/performance.html
+
+ **Kevin Samuel**, `Formations Python`_
+
+ I'm quite amazed, not just by the code quality (it's incredibly
+ readable and has more comment than code, wow), but the actual
+ amount of work you put at stuff that is *not* code:
+ documentation, benchmarking, implementation explanations. Even
+ the git log is clean and the unit tests run out of the box on
+ Python 2 and 3.
+
+ .. _`Formations Python`: http://formationspython.com/
+
+ **Mark Summerfield**, a short plea for `Python Sorted Collections`_
+
+ Python's "batteries included" standard library seems to have a battery
+ missing. And the argument that "we never had it before" has worn thin. It is
+ time that Python offered a full range of collection classes out of the box,
+ including sorted ones.
+
+ .. _`Python Sorted Collections`: http://www.qtrac.eu/pysorted.html
+
+ Features
+ --------
+
+ - Pure-Python
+ - Fully documented
+ - Benchmark comparison (alternatives, runtimes, load-factors)
+ - 100% test coverage
+ - Hours of stress testing
+ - Performance matters (often faster than C implementations)
+ - Compatible API (nearly identical to popular blist and rbtree modules)
+ - Feature-rich (e.g. get the five largest keys in a sorted dict: d.iloc[-5:])
+ - Pragmatic design (e.g. SortedSet is a Python set with a SortedList index)
+ - Developed on Python 2.7
+ - Tested on CPython 2.6, 2.7, 3.2, 3.3, 3.4 and PyPy 2.2+, PyPy3 2.3.1+
+
+ Quickstart
+ ----------
+
+ Installing SortedContainers is simple with
+ `pip <http://www.pip-installer.org/>`_::
+
+ > pip install sortedcontainers
+
+ You can access documentation in the interpreter with Python's built-in help
+ function:
+
+ ::
+
+ >>> from sortedcontainers import SortedList, SortedSet, SortedDict
+ >>> help(SortedList)
+
+ Documentation
+ -------------
+
+ Complete documentation including performance comparisons is available at
+ http://www.grantjenks.com/docs/sortedcontainers/ .
+
+ User Guide
+ ..........
+
+ For those wanting more details, this part of the documentation describes
+ introduction, implementation, performance, and development.
+
+ - `Introduction`_
+ - `Performance Comparison`_
+ - `Load Factor Performance Comparison`_
+ - `Runtime Performance Comparison`_
+ - `Simulated Workload Performance Comparison`_
+ - `Implementation Details`_
+ - `Developing and Contributing`_
+
+ .. _`Introduction`: http://www.grantjenks.com/docs/sortedcontainers/introduction.html
+ .. _`Performance Comparison`: http://www.grantjenks.com/docs/sortedcontainers/performance.html
+ .. _`Load Factor Performance Comparison`: http://www.grantjenks.com/docs/sortedcontainers/performance-load.html
+ .. _`Runtime Performance Comparison`: http://www.grantjenks.com/docs/sortedcontainers/performance-runtime.html
+ .. _`Simulated Workload Performance Comparison`: http://www.grantjenks.com/docs/sortedcontainers/performance-workload.html
+ .. _`Implementation Details`: http://www.grantjenks.com/docs/sortedcontainers/implementation.html
+ .. _`Developing and Contributing`: http://www.grantjenks.com/docs/sortedcontainers/development.html
+
+ API Documentation
+ .................
+
+ If you are looking for information on a specific function, class or method, this
+ part of the documentation is for you.
+
+ - `SortedList`_
+ - `SortedListWithKey`_
+ - `SortedDict`_
+ - `SortedSet`_
+
+ .. _`SortedList`: http://www.grantjenks.com/docs/sortedcontainers/sortedlist.html
+ .. _`SortedListWithKey`: http://www.grantjenks.com/docs/sortedcontainers/sortedlistwithkey.html
+ .. _`SortedDict`: http://www.grantjenks.com/docs/sortedcontainers/sorteddict.html
+ .. _`SortedSet`: http://www.grantjenks.com/docs/sortedcontainers/sortedset.html
+
+ Contribute
+ ----------
+
+ Collaborators are welcome!
+
+ #. Check for open issues or open a fresh issue to start a discussion around a
+ bug. There is a Contributor Friendly tag for issues that should be used by
+ people who are not very familiar with the codebase yet.
+ #. Fork `the repository <https://github.com/grantjenks/sorted_containers>`_ on
+ GitHub and start making your changes to a new branch.
+ #. Write a test which shows that the bug was fixed.
+ #. Send a pull request and bug the maintainer until it gets merged and
+ published. :)
+
+ Useful Links
+ ------------
+
+ - `SortedContainers Project @ GrantJenks.com`_
+ - `SortedContainers @ PyPI`_
+ - `SortedContainers @ Github`_
+ - `Issue Tracker`_
+
+ .. _`SortedContainers Project @ GrantJenks.com`: http://www.grantjenks.com/docs/sortedcontainers/
+ .. _`SortedContainers @ PyPI`: https://pypi.python.org/pypi/sortedcontainers
+ .. _`SortedContainers @ Github`: https://github.com/grantjenks/sorted_containers
+ .. _`Issue Tracker`: https://github.com/grantjenks/sorted_containers/issues
+
+ SortedContainers License
+ ------------------------
+
+ Copyright 2015 Grant Jenks
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+Platform: UNKNOWN
+Classifier: Development Status :: 4 - Beta
+Classifier: Intended Audience :: Developers
+Classifier: Natural Language :: English
+Classifier: License :: OSI Approved :: Apache Software License
+Classifier: Programming Language :: Python
+Classifier: Programming Language :: Python :: Implementation :: CPython
+Classifier: Programming Language :: Python :: Implementation :: PyPy
+Classifier: Programming Language :: Python :: 2.6
+Classifier: Programming Language :: Python :: 2.7
+Classifier: Programming Language :: Python :: 3
+Classifier: Programming Language :: Python :: 3.2
+Classifier: Programming Language :: Python :: 3.3
+Classifier: Programming Language :: Python :: 3.4
diff --git a/sortedcontainers.egg-info/SOURCES.txt b/sortedcontainers.egg-info/SOURCES.txt
new file mode 100644
index 0000000..0737f88
--- /dev/null
+++ b/sortedcontainers.egg-info/SOURCES.txt
@@ -0,0 +1,13 @@
+LICENSE
+MANIFEST.in
+README.rst
+setup.py
+sortedcontainers/__init__.py
+sortedcontainers/sorteddict.py
+sortedcontainers/sortedlist.py
+sortedcontainers/sortedlistwithkey.py
+sortedcontainers/sortedset.py
+sortedcontainers.egg-info/PKG-INFO
+sortedcontainers.egg-info/SOURCES.txt
+sortedcontainers.egg-info/dependency_links.txt
+sortedcontainers.egg-info/top_level.txt
\ No newline at end of file
diff --git a/sortedcontainers.egg-info/dependency_links.txt b/sortedcontainers.egg-info/dependency_links.txt
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/sortedcontainers.egg-info/dependency_links.txt
@@ -0,0 +1 @@
+
diff --git a/sortedcontainers.egg-info/top_level.txt b/sortedcontainers.egg-info/top_level.txt
new file mode 100644
index 0000000..4693a5a
--- /dev/null
+++ b/sortedcontainers.egg-info/top_level.txt
@@ -0,0 +1 @@
+sortedcontainers
diff --git a/sortedcontainers/__init__.py b/sortedcontainers/__init__.py
new file mode 100644
index 0000000..c65e8b5
--- /dev/null
+++ b/sortedcontainers/__init__.py
@@ -0,0 +1,55 @@
+# -*- coding: utf-8 -*-
+
+"""
+sortedcontainers Sorted Container Types Library
+===============================================
+
+SortedContainers is an Apache2 licensed containers library, written in
+pure-Python, and fast as C-extensions.
+
+Python's standard library is great until you need a sorted container type. Many
+will attest that you can get really far without one, but the moment you
+**really need** a sorted list, dict, or set, you're faced with a dozen
+different implementations, most using C-extensions without great documentation
+and benchmarking.
+
+Things shouldn't be this way. Not in Python.
+
+::
+
+ >>> from sortedcontainers import SortedList, SortedDict, SortedSet
+ >>> sl = SortedList(xrange(10000000))
+ >>> 1234567 in sl
+ True
+ >>> sl[7654321]
+ 7654321
+ >>> sl.add(1234567)
+ >>> sl.count(1234567)
+ 2
+ >>> sl *= 3
+ >>> len(sl)
+ 30000003
+
+SortedContainers takes all of the work out of Python sorted types - making your
+deployment and use of Python easy. There's no need to install a C compiler or
+pre-build and distribute custom extensions. Performance is a feature and
+testing has 100% coverage with unit tests and hours of stress.
+
+:copyright: (c) 2015 by Grant Jenks.
+:license: Apache 2.0, see LICENSE for more details.
+
+"""
+
+__title__ = 'sortedcontainers'
+__version__ = '0.9.6'
+__build__ = 0x000906
+__author__ = 'Grant Jenks'
+__license__ = 'Apache 2.0'
+__copyright__ = 'Copyright 2015 Grant Jenks'
+
+from .sortedlist import SortedList
+from .sortedset import SortedSet
+from .sorteddict import SortedDict
+from .sortedlistwithkey import SortedListWithKey
+
+__all__ = ['SortedList', 'SortedSet', 'SortedDict', 'SortedListWithKey']
diff --git a/sortedcontainers/sorteddict.py b/sortedcontainers/sorteddict.py
new file mode 100644
index 0000000..a2e0d25
--- /dev/null
+++ b/sortedcontainers/sorteddict.py
@@ -0,0 +1,718 @@
+# -*- coding: utf-8 -*-
+#
+# Sorted dict implementation.
+
+from .sortedset import SortedSet
+from .sortedlist import SortedList, recursive_repr
+from .sortedlistwithkey import SortedListWithKey
+from collections import Set, Sequence
+from collections import KeysView as AbstractKeysView
+from collections import ValuesView as AbstractValuesView
+from collections import ItemsView as AbstractItemsView
+
+from functools import wraps
+from sys import hexversion
+
+_NotGiven = object()
+
+def not26(func):
+ """Function decorator for methods not implemented in Python 2.6."""
+
+ @wraps(func)
+ def errfunc(*args, **kwargs):
+ raise NotImplementedError
+
+ if hexversion < 0x02070000:
+ return errfunc
+ else:
+ return func
+
+class _IlocWrapper:
+ def __init__(self, _dict):
+ self._dict = _dict
+ def __len__(self):
+ return len(self._dict)
+ def __getitem__(self, index):
+ """
+ Very efficiently return the key at index *index* in iteration. Supports
+ negative indices and slice notation. Raises IndexError on invalid
+ *index*.
+ """
+ return self._dict._list[index]
+ def __delitem__(self, index):
+ """
+ Remove the ``sdict[sdict.iloc[index]]`` from *sdict*. Supports negative
+ indices and slice notation. Raises IndexError on invalid *index*.
+ """
+ _temp = self._dict
+ _list = _temp._list
+ _delitem = _temp._delitem
+
+ if isinstance(index, slice):
+ keys = _list[index]
+ del _list[index]
+ for key in keys:
+ _delitem(key)
+ else:
+ key = _list[index]
+ del _list[index]
+ _delitem(key)
+
+class SortedDict(dict):
+ """
+ A SortedDict provides the same methods as a dict. Additionally, a
+ SortedDict efficiently maintains its keys in sorted order. Consequently, the
+ keys method will return the keys in sorted order, the popitem method will
+ remove the item with the highest key, etc.
+ """
+ def __init__(self, *args, **kwargs):
+ """
+ A SortedDict provides the same methods as a dict. Additionally, a
+ SortedDict efficiently maintains its keys in sorted order. Consequently,
+ the keys method will return the keys in sorted order, the popitem method
+ will remove the item with the highest key, etc.
+
+ An optional *key* argument defines a callable that, like the `key`
+ argument to Python's `sorted` function, extracts a comparison key from
+ each dict key. If no function is specified, the default compares the
+ dict keys directly. The `key` argument must be provided as a positional
+ argument and must come before all other arguments.
+
+ An optional *load* argument defines the load factor of the internal list
+ used to maintain sort order. If present, this argument must come before
+ an iterable. The default load factor of '1000' works well for lists from
+ tens to tens of millions of elements. Good practice is to use a value
+ that is the cube root of the list size. With billions of elements, the
... 3838 lines suppressed ...
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/sortedcontainers.git
More information about the Python-modules-commits
mailing list