Deprecate two methods (which I seriously doubt anyone ever used, but they were documented so...) because they cannot be implemented efficiently on top of collections.SortedDict in Python 2.7 and up.
This commit is contained in:
parent
9877d25dc6
commit
8b3c2f2c51
|
@ -1,6 +1,8 @@
|
||||||
import copy
|
import copy
|
||||||
|
import warning
|
||||||
from types import GeneratorType
|
from types import GeneratorType
|
||||||
|
|
||||||
|
|
||||||
class MergeDict(object):
|
class MergeDict(object):
|
||||||
"""
|
"""
|
||||||
A simple class for creating new "virtual" dictionaries that actually look
|
A simple class for creating new "virtual" dictionaries that actually look
|
||||||
|
@ -191,10 +193,17 @@ class SortedDict(dict):
|
||||||
|
|
||||||
def value_for_index(self, index):
|
def value_for_index(self, index):
|
||||||
"""Returns the value of the item at the given zero-based index."""
|
"""Returns the value of the item at the given zero-based index."""
|
||||||
|
# This, and insert() are deprecated because they cannot be implemented
|
||||||
|
# using collections.OrderedDict (Python 2.7 and up), which we'll
|
||||||
|
# eventually switch to
|
||||||
|
warning.warn(PendingDeprecationWarning,
|
||||||
|
"SortedDict.value_for_index is deprecated", stacklevel=2)
|
||||||
return self[self.keyOrder[index]]
|
return self[self.keyOrder[index]]
|
||||||
|
|
||||||
def insert(self, index, key, value):
|
def insert(self, index, key, value):
|
||||||
"""Inserts the key, value pair before the item with the given index."""
|
"""Inserts the key, value pair before the item with the given index."""
|
||||||
|
warning.warn(PendingDeprecationWarning,
|
||||||
|
"SortedDict.insert is deprecated", stacklevel=2)
|
||||||
if key in self.keyOrder:
|
if key in self.keyOrder:
|
||||||
n = self.keyOrder.index(key)
|
n = self.keyOrder.index(key)
|
||||||
del self.keyOrder[n]
|
del self.keyOrder[n]
|
||||||
|
|
|
@ -112,10 +112,14 @@ to distinguish caches by the ``Accept-language`` header.
|
||||||
|
|
||||||
.. method:: insert(index, key, value)
|
.. method:: insert(index, key, value)
|
||||||
|
|
||||||
|
.. deprecated:: 1.5
|
||||||
|
|
||||||
Inserts the key, value pair before the item with the given index.
|
Inserts the key, value pair before the item with the given index.
|
||||||
|
|
||||||
.. method:: value_for_index(index)
|
.. method:: value_for_index(index)
|
||||||
|
|
||||||
|
.. deprecated:: 1.5
|
||||||
|
|
||||||
Returns the value of the item at the given zero-based index.
|
Returns the value of the item at the given zero-based index.
|
||||||
|
|
||||||
Creating a new SortedDict
|
Creating a new SortedDict
|
||||||
|
|
Loading…
Reference in New Issue