6 from threading
import get_ident
as _get_ident
9 from thread
import get_ident
as _get_ident
11 from dummy_thread
import get_ident
as _get_ident
13 from _abcoll
import KeysView, ValuesView, ItemsView
19 'Dictionary that remembers insertion order' 31 '''Initialize an ordered dictionary. Signature is the same as for 32 regular dictionaries, but keyword arguments are not recommended 33 because their insertion order is arbitrary. 37 raise TypeError(
'expected at most 1 arguments, got %d' %
len(args))
40 except AttributeError:
42 root[:] = [root, root,
None]
46 def __setitem__(self, key, value, dict_setitem=dict.__setitem__):
47 'od.__setitem__(i, y) <==> od[i]=y' 53 last[1] = root[0] = self.
__map[key] = [last, root, key]
54 dict_setitem(self, key, value)
57 'od.__delitem__(y) <==> del od[y]' 60 dict_delitem(self, key)
61 link_prev, link_next, key = self.
__map.
pop(key)
62 link_prev[1] = link_next
63 link_next[0] = link_prev
66 'od.__iter__() <==> iter(od)' 69 while curr
is not root:
74 'od.__reversed__() <==> reversed(od)' 77 while curr
is not root:
82 'od.clear() -> None. Remove all items from od.' 87 root[:] = [root, root,
None]
89 except AttributeError:
94 '''od.popitem() -> (k, v), return and remove a (key, value) pair. 95 Pairs are returned in LIFO order if last is true or FIFO order if false. 99 raise KeyError(
'dictionary is empty')
113 value = dict.pop(self, key)
119 'od.keys() -> list of keys in od' 123 'od.values() -> list of values in od' 124 return [self[key]
for key
in self]
127 'od.items() -> list of (key, value) pairs in od' 128 return [(key, self[key])
for key
in self]
131 'od.iterkeys() -> an iterator over the keys in od' 135 'od.itervalues -> an iterator over the values in od' 140 'od.iteritems -> an iterator over the (key, value) items in od' 145 '''od.update(E, **F) -> None. Update od from dict/iterable E and F. 147 If E is a dict instance, does: for k in E: od[k] = E[k] 148 If E has a .keys() method, does: for k in E.keys(): od[k] = E[k] 149 Or if E is an iterable of items, does: for k, v in E: od[k] = v 150 In either case, this is followed by: for k, v in F.items(): od[k] = v 154 raise TypeError(
'update() takes at most 2 positional ' 155 'arguments (%d given)' % (
len(args),))
157 raise TypeError(
'update() takes at least 1 argument (0 given)')
163 if isinstance(other, dict):
165 self[key] = other[key]
166 elif hasattr(other,
'keys'):
167 for key
in other.keys():
168 self[key] = other[key]
170 for key, value
in other:
172 for key, value
in kwds.items():
179 def pop(self, key, default=__marker):
180 '''od.pop(k[,d]) -> v, remove specified key and return the corresponding value. 181 If key is not found, d is returned if given, otherwise KeyError is raised. 193 'od.setdefault(k[,d]) -> od.get(k,d), also set od[k]=d if k not in od' 200 'od.__repr__() <==> repr(od)' 201 call_key =
id(self), _get_ident()
202 if call_key
in _repr_running:
204 _repr_running[call_key] = 1
207 return '%s()' % (self.__class__.__name__,)
208 return '%s(%r)' % (self.__class__.__name__, self.
items())
210 del _repr_running[call_key]
213 'Return state information for pickling' 214 items = [[k, self[k]]
for k
in self]
215 inst_dict = vars(self).
copy()
217 inst_dict.pop(k,
None)
219 return (self.__class__, (items,), inst_dict)
220 return self.__class__, (items,)
223 'od.copy() -> a shallow copy of od' 224 return self.__class__(self)
228 '''OD.fromkeys(S[, v]) -> New ordered dictionary with keys from S 229 and values equal to v (which defaults to None). 238 '''od.__eq__(y) <==> od==y. Comparison to another OD is order-sensitive 239 while comparison to a regular mapping is order-insensitive. 242 if isinstance(other, OrderedDict):
243 return len(self)==
len(other)
and self.
items() == other.items()
244 return dict.__eq__(self, other)
247 return not self == other
252 "od.viewkeys() -> a set-like object providing a view on od's keys" 253 return KeysView(self)
256 "od.viewvalues() -> an object providing a view on od's values" 257 return ValuesView(self)
260 "od.viewitems() -> a set-like object providing a view on od's items" 261 return ItemsView(self)
268 OrderedDict.__init__(self, *args, **kwds)
273 OrderedDict.__setitem__(
274 self, key, val
if isinstance(val, list)
else [val])
281 if not isinstance(val, list):
285 for j
in val.reverse():
def __setitem__(self, key, value, dict_setitem=dict.__setitem__)
def insert(self, i, key, val)
def __delitem__(self, key, dict_delitem=dict.__delitem__)
def pop(self, key, default=__marker)
def __repr__(self, _repr_running={})
def popitem(self, last=True)
def __setitem__(self, key, val, i=None)
def __init__(self, args, kwds)
def __init__(self, args, kwds)
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
def fromkeys(cls, iterable, value=None)
def setdefault(self, key, default=None)