sortedcontainers v2.0.0 Release Notes
Release Date: 2018-05-18 // almost 6 years ago-
🔖 Version 2 represents a significant update to the source base. The code has been 🔨 refactored and modernized to embrace Python 3 semantics while also using 📚
autodoc
in Sphinx for more maintainable documentation. The core design and ✅ algorithms are all the same. Sorted Containers still supports and is tested on Python 2 but primary development is now on Python 3.6.🔖 Version 2 is developed on the
master
branch in the source repository and 🔖 Version 1 of Sorted Containers will be maintained on branchv1
.🔖 Version 3 of Sorted Containers will be released sometime after January 1, 2020 👍 and will drop support for Python 2.
At a high-level, changes can be categorized in three ways:
- :class:
SortedList
methods__setitem__
,append
,extend
, andinsert
all now raise :exc:NotImplementedError
. Useadd
orupdate
instead. Though it's possible to implement these methods, they were confusing, inefficient and wrongly used by some users. Sorted list implementations that need the functionality are encouraged to do so through subclassing. Branchv1
contains a reference implementation. - :class:
SortedDict
now uses Python 3 semantics for dict views. Theiterkeys
,iteritems
,itervalues
,viewkeys
,viewitems
, andviewvalues
methods have all been removed. Use thekeys
,items
, orvalues
methods which now return sorted dict views. :class:SortedKeysView
has also replacedSortedDict.iloc
as a better interface for indexing. - Method parameter names have changed to be more consistent with Python's
built-in data types:
val
has changed tovalue
,idx
has changed toindex
, andthat
has changed toother
.
API Changes
- 🗄 :class:
SortedListWithKey
is deprecated. Use :class:SortedKeyList
instead. The nameSortedListWithKey
remains as an alias forSortedKeyList
. The alias will be removed in Version 3. - 🚚
sortedcontainers.sortedlist.LOAD
has moved toSortedList.DEFAULT_LOAD_FACTOR
so that derived classes can customize the value. SortedList._half
andSortedList._dual
have been removed. UseSortedList._load
instead.- :func:
SortedList.add
parameterval
renamed tovalue
. - :func:
SortedList.__contains__
parameterval
renamed tovalue
. - :func:
SortedList.discard
parameterval
renamed tovalue
. - 🚚 :func:
SortedList.remove
parameterval
renamed tovalue
. - :func:
SortedList.__delitem__
parameteridx
renamed toindex
. - :func:
SortedList.__getitem__
parameteridx
renamed toindex
. - :func:
SortedList.__setitem__
now raises :exc:NotImplementedError
. Use :func:SortedList.__delitem__
and :func:SortedList.add
instead. - :func:
SortedList.bisect_left
parameterval
renamed tovalue
. - :func:
SortedList.bisect_right
parameterval
renamed tovalue
. - :func:
SortedList.bisect
parameterval
renamed tovalue
. - :func:
SortedList.count
parameterval
renamed tovalue
. - :func:
SortedList.append
now raises :exc:NotImplementedError
. Use :func:SortedList.add
instead. - :func:
SortedList.extend
now raises :exc:NotImplementedError
. Use :func:SortedList.update
instead. - :func:
SortedList.insert
now raises :exc:NotImplementedError
. Use :func:SortedList.add
instead. - :func:
SortedList.pop
parameteridx
renamed toindex
. - :func:
SortedList.index
parameterval
renamed tovalue
. - ➕ :func:
SortedList.__add__
parameterthat
renamed toother
. - :func:
SortedList.__iadd__
parameterthat
renamed toother
. - :func:
SortedList.__mul__
parameterthat
renamed tonum
. - :func:
SortedList.__imul__
parameterthat
renamed tonum
. - 👉
SortedList._make_cmp
renamed toSortedList.__make_cmp
. - :func:
SortedKeyList.add
parameterval
renamed tovalue
. - :func:
SortedKeyList.__contains__
parameterval
renamed tovalue
. - :func:
SortedKeyList.discard
parameterval
renamed tovalue
. - 🚚 :func:
SortedKeyList.remove
parameterval
renamed tovalue
. - :func:
SortedKeyList.bisect_left
parameterval
renamed tovalue
. - :func:
SortedKeyList.bisect_right
parameterval
renamed tovalue
. - :func:
SortedKeyList.bisect
parameterval
renamed tovalue
. - :func:
SortedKeyList.count
parameterval
renamed tovalue
. - :func:
SortedKeyList.append
now raises :exc:NotImplementedError
. Use :func:SortedKeyList.add
instead. - :func:
SortedKeyList.extend
now raises :exc:NotImplementedError
. Use :func:SortedKeyList.update
instead. - :func:
SortedKeyList.insert
now raises :exc:NotImplementedError
. Use :func:SortedKeyList.add
instead. - :func:
SortedKeyList.index
parameterval
renamed tovalue
. - ➕ :func:
SortedKeyList.__add__
parameterthat
renamed toother
. - :func:
SortedKeyList.__radd__
added. - :func:
SortedKeyList.__iadd__
parameterthat
renamed toother
. - :func:
SortedKeyList.__mul__
parameterthat
renamed tonum
. - :func:
SortedKeyList.__rmul__
added. - :func:
SortedKeyList.__imul__
parameterthat
renamed tonum
. - ✂ Removed
SortedDict.iloc
. Use :func:SortedDict.keys
and :class:SortedKeysView
instead. - :func:
SortedDict.fromkeys
parameterseq
renamed toiterable
. - :func:
SortedDict.keys
now returns :class:SortedKeysView
. - :func:
SortedDict.items
now returns :class:SortedItemsView
. - :func:
SortedDict.values
now returns :class:SortedValuesView
. - ✂ Removed
SortedDict.viewkeys
. Use :func:SortedDict.keys
instead. - ✂ Removed
SortedDict.viewitems
. Use :func:SortedDict.items
instead. - ✂ Removed
SortedDict.viewvalues
. Use :func:SortedDict.values
instead. - 🚚
SortedDict.iterkeys
removed. Use :func:SortedDict.keys
instead. - 🚚
SortedDict.iteritems
removed. Use :func:SortedDict.items
instead. - 🚚
SortedDict.itervalues
removed. Use :func:SortedDict.values
instead. - 0️⃣
SortedDict.popitem
now accepts an optionalindex
argument. Default-1
. sorteddict.KeysView
renamed to :class:SortedKeysView
.sorteddict.ItemsView
renamed to :class:SortedItemsView
.sorteddict.ValuesView
renamed to :class:SortedValuesView
.- Sorted dict views rely on collections abstract base classes: dict views and
sequence. The :func:
SortedKeysView.__getitem__
, :func:SortedItemsView.__getitem__
, and :func:SortedValuesView.__getitem__
methods are implemented and optimized. All other mixin methods use the default implementation provided by the base class. Prefer :class:SortedDict
methods to view methods when possible. - 👉
SortedSet._make_cmp
renamed toSortedSet.__make_cmp
. - :func:
SortedSet.symmetric_difference
parameterthat
renamed toother
. - :func:
SortedSet.symmetric_difference_update
parameterthat
renamed toother
.
Miscellaneous
- 📚 Sphinx
autodoc
now used for API documentation. - All benchmarks now run on CPython 3.6 unless otherwise noted.
- ✅ Testing now uses
pytest
rather thannose
. - 👷 AppVeyor CI testing added.
- ⚡️ Updated versions of alternative implementations.
- :class: