[Python-modules-commits] [sortedcontainers] 01/06: Import sortedcontainers_1.5.6.orig.tar.gz

Sandro Tosi morph at moszumanska.debian.org
Tue Dec 13 12:36:14 UTC 2016


This is an automated email from the git hooks/post-receive script.

morph pushed a commit to branch master
in repository sortedcontainers.

commit 7c80b2c231d7cb71b3a8df773d02437f77331fde
Author: Sandro Tosi <morph at debian.org>
Date:   Tue Dec 13 07:28:06 2016 -0500

    Import sortedcontainers_1.5.6.orig.tar.gz
---
 .travis.yml                                     |   1 +
 HISTORY.rst                                     | 254 ++++++++++++++++++++++++
 README.rst                                      |   6 +-
 docs/history.rst                                |   1 +
 docs/implementation.rst                         |   2 +-
 docs/index.rst                                  |   1 +
 sortedcontainers/__init__.py                    |   4 +-
 sortedcontainers/sortedlist.py                  |  92 ++++-----
 tests/test_coverage_sortedlist.py               |  11 +
 tests/test_coverage_sortedlistwithkey_modulo.py |   6 +-
 tox.ini                                         |   5 +-
 11 files changed, 327 insertions(+), 56 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 636a286..55285b3 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,3 +1,4 @@
+sudo: false
 language: python
 python:
   - "2.6"
diff --git a/HISTORY.rst b/HISTORY.rst
new file mode 100644
index 0000000..e9450b0
--- /dev/null
+++ b/HISTORY.rst
@@ -0,0 +1,254 @@
+Sorted Containers Release History
+=================================
+
+1.5.6 (2016-12-09)
+------------------
+
+**Bugfixes**
+
+* Changed ``SortedList.__setitem__`` to support slices that alias itself.
+
+
+1.5.5 (2016-12-05)
+------------------
+
+**Bugfixes**
+
+* Changed ``SortedList.extend`` to support empty iterables.
+
+1.5.4 (2016-10-16)
+------------------
+
+**Bugfixes**
+
+* Changed ``SortedList.__new__`` to call ``SortedListWithKey.__init__`` once
+  instead of twice.
+
+1.5.3 (2016-06-01)
+------------------
+
+**Miscellaneous**
+
+* Updated documentation with PyCon 2016 Talk.
+
+1.5.2 (2016-05-28)
+------------------
+
+**API Changes**
+
+* Added ``SortedDict.peekitem`` method.
+
+1.5.1 (2016-05-26)
+------------------
+
+**Miscellaneous**
+
+* Added support for PyLint and minor source changes.
+* Dropped Python 3.2 support from tox testing due to virtualenv limitations.
+
+1.5.0 (2016-05-26)
+------------------
+
+**Miscellaneous**
+
+* Added Performance at Scale documentation.
+
+1.4.3 (2015-12-03)
+------------------
+
+**Miscellaneous**
+
+* Updated documentation with SF Python 2015 Holiday Meetup Talk.
+
+1.4.2 (2015-10-20)
+------------------
+
+**API Changes**
+
+* Changed ``SortedList`` initializer to support key-argument callable and
+  automatically return ``SortedListWithKey`` when present.
+* Changed ``SortedListWithKey`` to inherit from ``SortedList``.
+* Changed ``SortedSet.__ior__`` to call `update` rather than `union`.
+* Changed SortedList comparison to match Sequence semantics as described in
+  CPython Language Reference Section 5.9.
+* Changed SortedSet comparison to raise NotImplemented on type mismatch.
+* Removed SortedList.as_list method. Use ``list(sorted_list)`` instead.
+* Removed SortedList._slice method. Use ``slice.indices`` instead.
+* Added private references to public methods for internal use to ease
+  method over-loading.
+
+**Bugfixes**
+
+* Changed sorteddict.ValuesView.count to correctly reference sorted dictionary.
+
+**Improvements**
+
+* ``SortedList.__getitem__`` now 35% faster for indexing at beginning and end.
+* ``SortedList.pop`` now 35% faster by inlining fast-paths.
+* ``del sorted_list[:]`` now calls `clear` and is much faster.
+* ``sorted_list[:] = values`` now calls `clear` and `update` and is much faster.
+
+**Miscellaneous**
+
+* Added Python 3.5 support in tox testing.
+* Added discussion of `ruamel.ordereddict.sorteddict` to performance
+  documentation.
+* Merged file ``sortedlistwithkey.py`` into ``sortedlist.py``.
+
+0.9.6 (2015-06-22)
+------------------
+
+**API Changes**
+
+* Added ``islice`` method to sorted list, dict, and set types.
+* Added ``irange`` and ``irange_key`` method to sorted list, dict, and set
+  types.
+
+0.9.5 (2015-03-16)
+------------------
+
+**API Changes**
+
+* Added ``bisect_key`` methods to sorted list, dict, and set types.
+* Added ``last=True`` argument to ``SortedDict.popitem``.
+
+0.9.4 (2014-12-04)
+------------------
+
+**Bugfixes**
+
+* Added implementation and testing for Python pickle module.
+
+0.9.3 (2014-11-30)
+------------------
+
+**API Changes**
+
+* Removed ``SortedListWithKeyPair`` type.
+
+**Improvements**
+
+* Changed type references to ``self.__class__`` as able.
+
+0.9.2 (2014-10-20)
+------------------
+
+**API Changes**
+
+* Removed ``value_orderable`` argument from ``SortedListWithKey`` initializer.
+* Added key-callable argument to ``SortedDict`` initializer.
+* Added key-callable argument to ``SortedSet`` initializer.
+
+**Improvements**
+
+* Changed ``SortedDict`` to inherit directly from ``dict``.
+
+**Miscellaneous**
+
+* Added PyPy3 support to tox testing.
+* Added ``SortedListWithKey`` to sorted list performance comparison
+  documentation.
+
+0.9.1 (2014-09-20)
+------------------
+
+**Bugfixes**
+
+* Changed ``SortedList.__setitem__`` with slices to correctly update internal
+  "maxes" index.
+
+0.9.0 (2014-09-17)
+------------------
+
+**API Changes**
+
+* Added ``__ior__``, ``__iand__``, ``__isub__``, and ``__ixor__`` methods to
+  ``SortedSet`` interface.
+
+**Improvements**
+
+* Changed position-based indexing to use dense tree-based index.
+
+**Miscellaneous**
+
+* Added workload-based performance comparison for sorted list: Priority Queue,
+  Multiset, etc.
+
+0.8.5 (2014-08-11)
+------------------
+
+**Bugfixes**
+
+* Changed copy methods to make shallow copies: values are not copied, only
+  references to values are copied.
+
+**Miscellaneous**
+
+* Added load-factor performance comparison documentation.
+
+0.8.4 (2014-07-29)
+------------------
+
+**API Changes**
+
+* Added ``value_orderable`` parameter to ``SortedListWithKey`` to support
+  incomparable value types.
+
+**Bugfixes**
+
+* Changed ``repr`` methods to prevent infinite recursion and allow easier
+  subclassing.
+
+0.8.3 (2014-07-07)
+------------------
+
+**Miscellaneous**
+
+* Added more testing for sorted lists with key-callable argument.
+
+0.8.2 (2014-06-13)
+------------------
+
+**API Changes**
+
+* Added ``SortedListWithKey`` type with implementation based on
+  ``(key, value)`` tuples.
+
+0.8.1 (2014-05-08)
+------------------
+
+**Bugfixes**
+
+* Added contains-key check in sorted dict equality comparisons.
+
+**Miscellaneous**
+
+* Added Python runtime comparison to documentation.
+* Added sorted dict and set comparison to benchmark documentation.
+* Added Travis-CI testing.
+
+0.8.0 (2014-04-08)
+------------------
+
+**API Changes**
+
+* Added ``bisect`` methods from ``SortedList`` to ``SortedDict`` interface.
+
+0.7.0 (2014-04-02)
+------------------
+
+**Miscellaneous**
+
+* Added Banyan module to benchmark documentation.
+
+0.6.0 (2014-03-18)
+------------------
+
+**Miscellaneous**
+
+* Added testing support for CPython 2.6, 2.7, 3.2, and 3.3 with full coverage.
+
+0.5.0 (2014-03-14)
+------------------
+
+* Initial release of sorted list, dict, and set types.
diff --git a/README.rst b/README.rst
index 0c2359c..0982780 100644
--- a/README.rst
+++ b/README.rst
@@ -15,7 +15,7 @@ and benchmarking.
 
 In Python, we can do better. And we can do it in pure-Python!
 
-::
+.. code-block:: python
 
     >>> sl = sortedcontainers.SortedList(xrange(10000000))
     >>> 1234567 in sl
@@ -109,7 +109,7 @@ Installing `SortedContainers`_ is simple with
 You can access documentation in the interpreter with Python's built-in help
 function:
 
-::
+.. code-block:: python
 
     >>> from sortedcontainers import SortedList, SortedSet, SortedDict
     >>> help(SortedList)
@@ -134,6 +134,7 @@ introduction, implementation, performance, and development.
 - `Implementation Details`_
 - `Performance at Scale`_
 - `Developing and Contributing`_
+- `Release History`_
 
 .. _`Introduction`: http://www.grantjenks.com/docs/sortedcontainers/introduction.html
 .. _`Performance Comparison`: http://www.grantjenks.com/docs/sortedcontainers/performance.html
@@ -143,6 +144,7 @@ introduction, implementation, performance, and development.
 .. _`Implementation Details`: http://www.grantjenks.com/docs/sortedcontainers/implementation.html
 .. _`Performance at Scale`: http://www.grantjenks.com/docs/sortedcontainers/performance-scale.html
 .. _`Developing and Contributing`: http://www.grantjenks.com/docs/sortedcontainers/development.html
+.. _`Release History`: http://www.grantjenks.com/docs/sortedcontainers/history.html
 
 API Documentation
 .................
diff --git a/docs/history.rst b/docs/history.rst
new file mode 100644
index 0000000..2506499
--- /dev/null
+++ b/docs/history.rst
@@ -0,0 +1 @@
+.. include:: ../HISTORY.rst
diff --git a/docs/implementation.rst b/docs/implementation.rst
index b5db3c0..8f38fe7 100644
--- a/docs/implementation.rst
+++ b/docs/implementation.rst
@@ -143,7 +143,7 @@ Maintaining the position index in this way has several advantages:
   to this is when a new sublist is created/deleted. In those scenarios the
   entire index is deleted and not rebuilt until needed.
 
-The construction and maintainence of the positional index is unusual compared
+The construction and maintenance of the positional index is unusual compared
 to other traditional designs. Whether the design is novel, I (Grant Jenks) do
 not know. Until shown otherwise, I would like to refer to it as the "Jenks"
 index.
diff --git a/docs/index.rst b/docs/index.rst
index 3a39008..9a3dba3 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -125,6 +125,7 @@ introduction, implementation, performance, and development.
    implementation
    performance-scale
    development
+   history
 
 API Documentation
 -----------------
diff --git a/sortedcontainers/__init__.py b/sortedcontainers/__init__.py
index e34a7c4..5a7115b 100644
--- a/sortedcontainers/__init__.py
+++ b/sortedcontainers/__init__.py
@@ -45,8 +45,8 @@ from .sorteddict import SortedDict
 __all__ = ['SortedList', 'SortedSet', 'SortedDict', 'SortedListWithKey']
 
 __title__ = 'sortedcontainers'
-__version__ = '1.5.3'
-__build__ = 0x010503
+__version__ = '1.5.6'
+__build__ = 0x010506
 __author__ = 'Grant Jenks'
 __license__ = 'Apache 2.0'
 __copyright__ = 'Copyright 2016 Grant Jenks'
diff --git a/sortedcontainers/sortedlist.py b/sortedcontainers/sortedlist.py
index 6127883..40c7ea0 100644
--- a/sortedcontainers/sortedlist.py
+++ b/sortedcontainers/sortedlist.py
@@ -100,11 +100,12 @@ class SortedList(MutableSequence):
         on your usage.  It's best to leave the load factor at the default until
         you start benchmarking.
         """
+        # pylint: disable=unused-argument
         if key is None:
             return object.__new__(cls)
         else:
             if cls is SortedList:
-                return SortedListWithKey(iterable=iterable, key=key, load=load)
+                return object.__new__(SortedListWithKey)
             else:
                 raise TypeError('inherit SortedListWithKey for key argument')
 
@@ -365,7 +366,7 @@ class SortedList(MutableSequence):
 
         _index = self._index
 
-        if not len(_index):
+        if not _index:
             self._build_index()
 
         total = 0
@@ -680,13 +681,13 @@ class SortedList(MutableSequence):
                 raise ValueError(msg)
 
     def __setitem__(self, index, value):
-        """
-        Replace the item at position *index* with *value*.
+        """Replace item at position *index* with *value*.
 
-        Supports slice notation. Raises a :exc:`ValueError` if the sort order
+        Supports slice notation. Raises :exc:`ValueError` if the sort order
         would be violated. When used with a slice and iterable, the
-        :exc:`ValueError` is raised before the list is mutated if the sort order
-        would be violated by the operation.
+        :exc:`ValueError` is raised before the list is mutated if the sort
+        order would be violated by the operation.
+
         """
         _lists = self._lists
         _maxes = self._maxes
@@ -694,20 +695,21 @@ class SortedList(MutableSequence):
         _pos = self._pos
 
         if isinstance(index, slice):
-            start, stop, step = index.indices(self._len)
+            _len = self._len
+            start, stop, step = index.indices(_len)
             indices = range(start, stop, step)
 
-            if step != 1:
-                if not hasattr(value, '__len__'):
-                    value = list(value)
+            # Copy value to avoid aliasing issues with self and cases where an
+            # iterator is given.
 
-                indices = list(indices)
+            values = tuple(value)
 
-                if len(value) != len(indices):
+            if step != 1:
+                if len(values) != len(indices):
                     raise ValueError(
-                        'attempt to assign sequence of size {0}'
-                        ' to extended slice of size {1}'
-                        .format(len(value), len(indices)))
+                        'attempt to assign sequence of size %s'
+                        ' to extended slice of size %s'
+                        % (len(values), len(indices)))
 
                 # Keep a log of values that are set so that we can
                 # roll back changes if ordering is violated.
@@ -715,7 +717,7 @@ class SortedList(MutableSequence):
                 log = []
                 _append = log.append
 
-                for idx, val in zip(indices, value):
+                for idx, val in zip(indices, values):
                     pos, loc = _pos(idx)
                     _append((idx, _lists[pos][loc], val))
                     _lists[pos][loc] = val
@@ -725,14 +727,14 @@ class SortedList(MutableSequence):
                 try:
                     # Validate ordering of new values.
 
-                    for idx, oldval, newval in log:
+                    for idx, _, newval in log:
                         _check_order(idx, newval)
 
                 except ValueError:
 
                     # Roll back changes from log.
 
-                    for idx, oldval, newval in log:
+                    for idx, oldval, _ in log:
                         pos, loc = _pos(idx)
                         _lists[pos][loc] = oldval
                         if len(_lists[pos]) == (loc + 1):
@@ -740,42 +742,33 @@ class SortedList(MutableSequence):
 
                     raise
             else:
-                if start == 0 and stop == self._len:
+                if start == 0 and stop == _len:
                     self._clear()
-                    return self._update(value)
-
-                # Test ordering using indexing. If the given value
-                # isn't a Sequence, convert it to a tuple.
+                    return self._update(values)
 
-                if not isinstance(value, Sequence):
-                    value = tuple(value) # pylint: disable=redefined-variable-type
+                if values:
 
-                # Check that the given values are ordered properly.
+                    # Check that given values are ordered properly.
 
-                iterator = range(1, len(value))
+                    alphas = iter(values)
+                    betas = iter(values)
+                    next(betas)
+                    pairs = zip(alphas, betas)
 
-                if not all(value[pos - 1] <= value[pos] for pos in iterator):
-                    raise ValueError('given sequence not in sort order')
+                    if not all(alpha <= beta for alpha, beta in pairs):
+                        raise ValueError('given values not in sort order')
 
-                # Check ordering in context of sorted list.
+                    # Check ordering in context of sorted list.
 
-                if not start or not len(value):
-                    # Nothing to check on the lhs.
-                    pass
-                else:
-                    if self._getitem(start - 1) > value[0]:
-                        msg = '{0} not in sort order at index {1}'.format(repr(value[0]), start)
-                        raise ValueError(msg)
+                    if start and self._getitem(start - 1) > values[0]:
+                        message = '%s not in sort order at index %s' % (
+                            repr(values[0]), start)
+                        raise ValueError(message)
 
-                if stop == len(self) or not len(value):
-                    # Nothing to check on the rhs.
-                    pass
-                else:
-                    # "stop" is exclusive so we don't need
-                    # to add one for the index.
-                    if self._getitem(stop) < value[-1]:
-                        msg = '{0} not in sort order at index {1}'.format(repr(value[-1]), stop)
-                        raise ValueError(msg)
+                    if stop != _len and self._getitem(stop) < values[-1]:
+                        message = '%s not in sort order at index %s' % (
+                            repr(values[-1]), stop)
+                        raise ValueError(message)
 
                 # Delete the existing values.
 
@@ -784,7 +777,7 @@ class SortedList(MutableSequence):
                 # Insert the new values.
 
                 _insert = self.insert
-                for idx, val in enumerate(value):
+                for idx, val in enumerate(values):
                     _insert(start + idx, val)
         else:
             pos, loc = _pos(index)
@@ -1072,6 +1065,9 @@ class SortedList(MutableSequence):
         if not isinstance(values, list):
             values = list(values)
 
+        if not values:
+            return
+
         if any(values[pos - 1] > values[pos]
                for pos in range(1, len(values))):
             raise ValueError('given sequence not in sort order')
diff --git a/tests/test_coverage_sortedlist.py b/tests/test_coverage_sortedlist.py
index 573d6f9..8109199 100644
--- a/tests/test_coverage_sortedlist.py
+++ b/tests/test_coverage_sortedlist.py
@@ -274,6 +274,11 @@ def test_setitem_slice():
     assert slt == list(range(10, 90))
     slt._check()
 
+def test_setitem_slice_aliasing():
+    slt = SortedList([0])
+    slt[1:1] = slt
+    assert slt == [0, 0]
+
 @raises(ValueError)
 def test_setitem_slice_bad():
     slt = SortedList(range(100), load=17)
@@ -468,9 +473,15 @@ def test_append_valueerror():
 def test_extend():
     slt = SortedList(load=17)
 
+    slt.extend([])
+    slt._check()
+
     slt.extend(range(100))
     slt._check()
 
+    slt.extend([])
+    slt._check()
+
     slt.extend(list(range(100, 200)))
     slt._check()
 
diff --git a/tests/test_coverage_sortedlistwithkey_modulo.py b/tests/test_coverage_sortedlistwithkey_modulo.py
index 8268689..4632ea8 100644
--- a/tests/test_coverage_sortedlistwithkey_modulo.py
+++ b/tests/test_coverage_sortedlistwithkey_modulo.py
@@ -38,14 +38,16 @@ def test_init():
     slt._check()
 
 def test_new():
-    slt = SortedList(key=modulo)
+    slt = SortedList(iter(range(1000)), key=modulo)
+    assert slt == sorted(range(1000), key=modulo)
     slt._check()
 
     assert isinstance(slt, SortedList)
     assert isinstance(slt, SortedListWithKey)
     assert type(slt) == SortedListWithKey
 
-    slt = SortedListWithKey(key=modulo)
+    slt = SortedListWithKey(iter(range(1000)), key=modulo)
+    assert slt == sorted(range(1000), key=modulo)
     slt._check()
 
     assert isinstance(slt, SortedList)
diff --git a/tox.ini b/tox.ini
index fa5d0a3..e1091f0 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,5 +1,8 @@
 [tox]
-envlist=py26,py27,py33,py34,py35
+envlist=py26,py27,py33,py34,py35,pypy,pypy3,lint
 [testenv]
 deps=nose
 commands=nosetests
+[testenv:lint]
+deps=pylint
+commands=pylint --rcfile=.pylintrc --reports=n --output-format=colorized sortedcontainers

-- 
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