Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | Static Private Attributes
weakref.WeakValueDictionary Class Reference
Inheritance diagram for weakref.WeakValueDictionary:
Inheritance graph
[legend]
Collaboration diagram for weakref.WeakValueDictionary:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def __getitem__
def __delitem__
def __len__
def __contains__
def __repr__
def __setitem__
def copy
def __deepcopy__
def get
def items
def keys
def itervaluerefs
def values
def popitem
def pop
def setdefault
def update
def valuerefs
def clear
def update
def __eq__
def __ne__
def __subclasshook__
def __subclasshook__
def __subclasshook__
def __new__
def __new__
def __new__
def register
def register
def register
def __instancecheck__
def __instancecheck__
def __instancecheck__
def __subclasscheck__
def __subclasscheck__
def __subclasscheck__
def __iter__

Public Attributes

 data

Private Member Functions

def _commit_removals

Private Attributes

 _remove
 _pending_removals
 _iterating

Static Private Attributes

 __copy__ = copy
 __iter__ = keys

Detailed Description

Mapping class that references values weakly.

Entries in the dictionary will be discarded when no strong
reference to the value exists anymore

Definition at line 33 of file weakref.py.


Constructor & Destructor Documentation

def weakref.WeakValueDictionary.__init__ (   self,
  args,
  kw 
)

Definition at line 45 of file weakref.py.

00045 
00046     def __init__(self, *args, **kw):
00047         def remove(wr, selfref=ref(self)):
00048             self = selfref()
00049             if self is not None:
00050                 if self._iterating:
00051                     self._pending_removals.append(wr.key)
00052                 else:
00053                     del self.data[wr.key]
00054         self._remove = remove
00055         # A list of keys to be removed
00056         self._pending_removals = []
00057         self._iterating = set()
00058         self.data = d = {}
00059         self.update(*args, **kw)

Here is the call graph for this function:

Here is the caller graph for this function:


Member Function Documentation

def weakref.WeakValueDictionary.__contains__ (   self,
  key 
)

Reimplemented from _abcoll.Mapping.

Definition at line 83 of file weakref.py.

00083 
00084     def __contains__(self, key):
00085         try:
00086             o = self.data[key]()
00087         except KeyError:
00088             return False
00089         return o is not None

def weakref.WeakValueDictionary.__deepcopy__ (   self,
  memo 
)

Definition at line 108 of file weakref.py.

00108 
00109     def __deepcopy__(self, memo):
00110         from copy import deepcopy
00111         new = self.__class__()
00112         for key, wr in self.data.items():
00113             o = wr()
00114             if o is not None:
00115                 new[deepcopy(key, memo)] = o
00116         return new

Here is the call graph for this function:

def weakref.WeakValueDictionary.__delitem__ (   self,
  key 
)

Reimplemented from _abcoll.MutableMapping.

Definition at line 75 of file weakref.py.

00075 
00076     def __delitem__(self, key):
00077         if self._pending_removals:
00078             self._commit_removals()
00079         del self.data[key]

Here is the call graph for this function:

def _abcoll.Mapping.__eq__ (   self,
  other 
) [inherited]

Definition at line 380 of file _abcoll.py.

00380 
00381     def __eq__(self, other):
00382         if not isinstance(other, Mapping):
00383             return NotImplemented
00384         return dict(self.items()) == dict(other.items())

Here is the call graph for this function:

Here is the caller graph for this function:

def weakref.WeakValueDictionary.__getitem__ (   self,
  key 
)

Reimplemented from _abcoll.Mapping.

Definition at line 68 of file weakref.py.

00068 
00069     def __getitem__(self, key):
00070         o = self.data[key]()
00071         if o is None:
00072             raise KeyError(key)
00073         else:
00074             return o

def abc.ABCMeta.__instancecheck__ (   cls,
  instance 
) [inherited]
Override for isinstance(instance, cls).

Definition at line 158 of file abc.py.

00158 
00159     def __instancecheck__(cls, instance):
00160         """Override for isinstance(instance, cls)."""
00161         # Inline the cache checking
00162         subclass = instance.__class__
00163         if subclass in cls._abc_cache:
00164             return True
00165         subtype = type(instance)
00166         if subtype is subclass:
00167             if (cls._abc_negative_cache_version ==
00168                 ABCMeta._abc_invalidation_counter and
00169                 subclass in cls._abc_negative_cache):
00170                 return False
00171             # Fall back to the subclass check.
00172             return cls.__subclasscheck__(subclass)
00173         return any(cls.__subclasscheck__(c) for c in {subclass, subtype})

Here is the call graph for this function:

def abc.ABCMeta.__instancecheck__ (   cls,
  instance 
) [inherited]
Override for isinstance(instance, cls).

Definition at line 158 of file abc.py.

00158 
00159     def __instancecheck__(cls, instance):
00160         """Override for isinstance(instance, cls)."""
00161         # Inline the cache checking
00162         subclass = instance.__class__
00163         if subclass in cls._abc_cache:
00164             return True
00165         subtype = type(instance)
00166         if subtype is subclass:
00167             if (cls._abc_negative_cache_version ==
00168                 ABCMeta._abc_invalidation_counter and
00169                 subclass in cls._abc_negative_cache):
00170                 return False
00171             # Fall back to the subclass check.
00172             return cls.__subclasscheck__(subclass)
00173         return any(cls.__subclasscheck__(c) for c in {subclass, subtype})

Here is the call graph for this function:

def abc.ABCMeta.__instancecheck__ (   cls,
  instance 
) [inherited]
Override for isinstance(instance, cls).

Definition at line 158 of file abc.py.

00158 
00159     def __instancecheck__(cls, instance):
00160         """Override for isinstance(instance, cls)."""
00161         # Inline the cache checking
00162         subclass = instance.__class__
00163         if subclass in cls._abc_cache:
00164             return True
00165         subtype = type(instance)
00166         if subtype is subclass:
00167             if (cls._abc_negative_cache_version ==
00168                 ABCMeta._abc_invalidation_counter and
00169                 subclass in cls._abc_negative_cache):
00170                 return False
00171             # Fall back to the subclass check.
00172             return cls.__subclasscheck__(subclass)
00173         return any(cls.__subclasscheck__(c) for c in {subclass, subtype})

Here is the call graph for this function:

def _abcoll.Iterable.__iter__ (   self) [inherited]

Reimplemented in collections.UserDict, test.support.EnvironmentVarGuard, collections._ChainMap, _abcoll.Sequence, os._Environ, _abcoll.ItemsView, _abcoll.KeysView, shelve.Shelf, and _abcoll.Iterator.

Definition at line 69 of file _abcoll.py.

00069 
00070     def __iter__(self):
00071         while False:
00072             yield None

Reimplemented from _abcoll.Sized.

Definition at line 80 of file weakref.py.

00080 
00081     def __len__(self):
00082         return sum(wr() is not None for wr in self.data.values())

Here is the call graph for this function:

def _abcoll.Mapping.__ne__ (   self,
  other 
) [inherited]

Definition at line 385 of file _abcoll.py.

00385 
00386     def __ne__(self, other):
00387         return not (self == other)
00388 

def abc.ABCMeta.__new__ (   mcls,
  name,
  bases,
  namespace 
) [inherited]

Definition at line 116 of file abc.py.

00116 
00117     def __new__(mcls, name, bases, namespace):
00118         cls = super().__new__(mcls, name, bases, namespace)
00119         # Compute set of abstract method names
00120         abstracts = {name
00121                      for name, value in namespace.items()
00122                      if getattr(value, "__isabstractmethod__", False)}
00123         for base in bases:
00124             for name in getattr(base, "__abstractmethods__", set()):
00125                 value = getattr(cls, name, None)
00126                 if getattr(value, "__isabstractmethod__", False):
00127                     abstracts.add(name)
00128         cls.__abstractmethods__ = frozenset(abstracts)
00129         # Set up inheritance registry
00130         cls._abc_registry = WeakSet()
00131         cls._abc_cache = WeakSet()
00132         cls._abc_negative_cache = WeakSet()
00133         cls._abc_negative_cache_version = ABCMeta._abc_invalidation_counter
00134         return cls

Here is the call graph for this function:

def abc.ABCMeta.__new__ (   mcls,
  name,
  bases,
  namespace 
) [inherited]

Definition at line 116 of file abc.py.

00116 
00117     def __new__(mcls, name, bases, namespace):
00118         cls = super().__new__(mcls, name, bases, namespace)
00119         # Compute set of abstract method names
00120         abstracts = {name
00121                      for name, value in namespace.items()
00122                      if getattr(value, "__isabstractmethod__", False)}
00123         for base in bases:
00124             for name in getattr(base, "__abstractmethods__", set()):
00125                 value = getattr(cls, name, None)
00126                 if getattr(value, "__isabstractmethod__", False):
00127                     abstracts.add(name)
00128         cls.__abstractmethods__ = frozenset(abstracts)
00129         # Set up inheritance registry
00130         cls._abc_registry = WeakSet()
00131         cls._abc_cache = WeakSet()
00132         cls._abc_negative_cache = WeakSet()
00133         cls._abc_negative_cache_version = ABCMeta._abc_invalidation_counter
00134         return cls

Here is the call graph for this function:

def abc.ABCMeta.__new__ (   mcls,
  name,
  bases,
  namespace 
) [inherited]

Definition at line 116 of file abc.py.

00116 
00117     def __new__(mcls, name, bases, namespace):
00118         cls = super().__new__(mcls, name, bases, namespace)
00119         # Compute set of abstract method names
00120         abstracts = {name
00121                      for name, value in namespace.items()
00122                      if getattr(value, "__isabstractmethod__", False)}
00123         for base in bases:
00124             for name in getattr(base, "__abstractmethods__", set()):
00125                 value = getattr(cls, name, None)
00126                 if getattr(value, "__isabstractmethod__", False):
00127                     abstracts.add(name)
00128         cls.__abstractmethods__ = frozenset(abstracts)
00129         # Set up inheritance registry
00130         cls._abc_registry = WeakSet()
00131         cls._abc_cache = WeakSet()
00132         cls._abc_negative_cache = WeakSet()
00133         cls._abc_negative_cache_version = ABCMeta._abc_invalidation_counter
00134         return cls

Here is the call graph for this function:

Definition at line 90 of file weakref.py.

00090 
00091     def __repr__(self):
00092         return "<WeakValueDictionary at %s>" % id(self)

def weakref.WeakValueDictionary.__setitem__ (   self,
  key,
  value 
)

Reimplemented from _abcoll.MutableMapping.

Definition at line 93 of file weakref.py.

00093 
00094     def __setitem__(self, key, value):
00095         if self._pending_removals:
00096             self._commit_removals()
00097         self.data[key] = KeyedRef(value, self._remove, key)

Here is the call graph for this function:

def abc.ABCMeta.__subclasscheck__ (   cls,
  subclass 
) [inherited]
Override for issubclass(subclass, cls).

Definition at line 174 of file abc.py.

00174 
00175     def __subclasscheck__(cls, subclass):
00176         """Override for issubclass(subclass, cls)."""
00177         # Check cache
00178         if subclass in cls._abc_cache:
00179             return True
00180         # Check negative cache; may have to invalidate
00181         if cls._abc_negative_cache_version < ABCMeta._abc_invalidation_counter:
00182             # Invalidate the negative cache
00183             cls._abc_negative_cache = WeakSet()
00184             cls._abc_negative_cache_version = ABCMeta._abc_invalidation_counter
00185         elif subclass in cls._abc_negative_cache:
00186             return False
00187         # Check the subclass hook
00188         ok = cls.__subclasshook__(subclass)
00189         if ok is not NotImplemented:
00190             assert isinstance(ok, bool)
00191             if ok:
00192                 cls._abc_cache.add(subclass)
00193             else:
00194                 cls._abc_negative_cache.add(subclass)
00195             return ok
00196         # Check if it's a direct subclass
00197         if cls in getattr(subclass, '__mro__', ()):
00198             cls._abc_cache.add(subclass)
00199             return True
00200         # Check if it's a subclass of a registered class (recursive)
00201         for rcls in cls._abc_registry:
00202             if issubclass(subclass, rcls):
00203                 cls._abc_cache.add(subclass)
00204                 return True
00205         # Check if it's a subclass of a subclass (recursive)
00206         for scls in cls.__subclasses__():
00207             if issubclass(subclass, scls):
00208                 cls._abc_cache.add(subclass)
00209                 return True
00210         # No dice; update negative cache
00211         cls._abc_negative_cache.add(subclass)
00212         return False

Here is the call graph for this function:

def abc.ABCMeta.__subclasscheck__ (   cls,
  subclass 
) [inherited]
Override for issubclass(subclass, cls).

Definition at line 174 of file abc.py.

00174 
00175     def __subclasscheck__(cls, subclass):
00176         """Override for issubclass(subclass, cls)."""
00177         # Check cache
00178         if subclass in cls._abc_cache:
00179             return True
00180         # Check negative cache; may have to invalidate
00181         if cls._abc_negative_cache_version < ABCMeta._abc_invalidation_counter:
00182             # Invalidate the negative cache
00183             cls._abc_negative_cache = WeakSet()
00184             cls._abc_negative_cache_version = ABCMeta._abc_invalidation_counter
00185         elif subclass in cls._abc_negative_cache:
00186             return False
00187         # Check the subclass hook
00188         ok = cls.__subclasshook__(subclass)
00189         if ok is not NotImplemented:
00190             assert isinstance(ok, bool)
00191             if ok:
00192                 cls._abc_cache.add(subclass)
00193             else:
00194                 cls._abc_negative_cache.add(subclass)
00195             return ok
00196         # Check if it's a direct subclass
00197         if cls in getattr(subclass, '__mro__', ()):
00198             cls._abc_cache.add(subclass)
00199             return True
00200         # Check if it's a subclass of a registered class (recursive)
00201         for rcls in cls._abc_registry:
00202             if issubclass(subclass, rcls):
00203                 cls._abc_cache.add(subclass)
00204                 return True
00205         # Check if it's a subclass of a subclass (recursive)
00206         for scls in cls.__subclasses__():
00207             if issubclass(subclass, scls):
00208                 cls._abc_cache.add(subclass)
00209                 return True
00210         # No dice; update negative cache
00211         cls._abc_negative_cache.add(subclass)
00212         return False

Here is the call graph for this function:

def abc.ABCMeta.__subclasscheck__ (   cls,
  subclass 
) [inherited]
Override for issubclass(subclass, cls).

Definition at line 174 of file abc.py.

00174 
00175     def __subclasscheck__(cls, subclass):
00176         """Override for issubclass(subclass, cls)."""
00177         # Check cache
00178         if subclass in cls._abc_cache:
00179             return True
00180         # Check negative cache; may have to invalidate
00181         if cls._abc_negative_cache_version < ABCMeta._abc_invalidation_counter:
00182             # Invalidate the negative cache
00183             cls._abc_negative_cache = WeakSet()
00184             cls._abc_negative_cache_version = ABCMeta._abc_invalidation_counter
00185         elif subclass in cls._abc_negative_cache:
00186             return False
00187         # Check the subclass hook
00188         ok = cls.__subclasshook__(subclass)
00189         if ok is not NotImplemented:
00190             assert isinstance(ok, bool)
00191             if ok:
00192                 cls._abc_cache.add(subclass)
00193             else:
00194                 cls._abc_negative_cache.add(subclass)
00195             return ok
00196         # Check if it's a direct subclass
00197         if cls in getattr(subclass, '__mro__', ()):
00198             cls._abc_cache.add(subclass)
00199             return True
00200         # Check if it's a subclass of a registered class (recursive)
00201         for rcls in cls._abc_registry:
00202             if issubclass(subclass, rcls):
00203                 cls._abc_cache.add(subclass)
00204                 return True
00205         # Check if it's a subclass of a subclass (recursive)
00206         for scls in cls.__subclasses__():
00207             if issubclass(subclass, scls):
00208                 cls._abc_cache.add(subclass)
00209                 return True
00210         # No dice; update negative cache
00211         cls._abc_negative_cache.add(subclass)
00212         return False

Here is the call graph for this function:

def _abcoll.Iterable.__subclasshook__ (   cls,
  C 
) [inherited]

Reimplemented in _abcoll.Iterator.

Definition at line 74 of file _abcoll.py.

00074 
00075     def __subclasshook__(cls, C):
00076         if cls is Iterable:
00077             if any("__iter__" in B.__dict__ for B in C.__mro__):
00078                 return True
00079         return NotImplemented
00080 

Here is the call graph for this function:

def _abcoll.Sized.__subclasshook__ (   cls,
  C 
) [inherited]

Definition at line 119 of file _abcoll.py.

00119 
00120     def __subclasshook__(cls, C):
00121         if cls is Sized:
00122             if any("__len__" in B.__dict__ for B in C.__mro__):
00123                 return True
00124         return NotImplemented
00125 

Here is the call graph for this function:

def _abcoll.Container.__subclasshook__ (   cls,
  C 
) [inherited]

Definition at line 133 of file _abcoll.py.

00133 
00134     def __subclasshook__(cls, C):
00135         if cls is Container:
00136             if any("__contains__" in B.__dict__ for B in C.__mro__):
00137                 return True
00138         return NotImplemented
00139 

Here is the call graph for this function:

Definition at line 60 of file weakref.py.

00060 
00061     def _commit_removals(self):
00062         l = self._pending_removals
00063         d = self.data
00064         # We shouldn't encounter any KeyError, because this method should
00065         # always be called *before* mutating the dict.
00066         while l:
00067             del d[l.pop()]

Here is the caller graph for this function:

def _abcoll.MutableMapping.clear (   self) [inherited]

Reimplemented in collections._ChainMap.

Definition at line 486 of file _abcoll.py.

00486 
00487     def clear(self):
00488         try:
00489             while True:
00490                 self.popitem()
00491         except KeyError:
00492             pass

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 98 of file weakref.py.

00098 
00099     def copy(self):
00100         new = WeakValueDictionary()
00101         for key, wr in self.data.items():
00102             o = wr()
00103             if o is not None:
00104                 new[key] = o
00105         return new

def weakref.WeakValueDictionary.get (   self,
  key,
  default = None 
)

Reimplemented from _abcoll.Mapping.

Definition at line 117 of file weakref.py.

00117 
00118     def get(self, key, default=None):
00119         try:
00120             wr = self.data[key]
00121         except KeyError:
00122             return default
00123         else:
00124             o = wr()
00125             if o is None:
00126                 # This should only happen
00127                 return default
00128             else:
00129                 return o

Here is the caller graph for this function:

Reimplemented from _abcoll.Mapping.

Definition at line 130 of file weakref.py.

00130 
00131     def items(self):
00132         with _IterationGuard(self):
00133             for k, wr in self.data.items():
00134                 v = wr()
00135                 if v is not None:
00136                     yield k, v

Here is the caller graph for this function:

Return an iterator that yields the weak references to the values.

The references are not guaranteed to be 'live' at the time
they are used, so the result of calling the references needs
to be checked before being used.  This can be used to avoid
creating references that will cause the garbage collector to
keep the values around longer than needed.

Definition at line 145 of file weakref.py.

00145 
00146     def itervaluerefs(self):
00147         """Return an iterator that yields the weak references to the values.
00148 
00149         The references are not guaranteed to be 'live' at the time
00150         they are used, so the result of calling the references needs
00151         to be checked before being used.  This can be used to avoid
00152         creating references that will cause the garbage collector to
00153         keep the values around longer than needed.
00154 
00155         """
00156         with _IterationGuard(self):
00157             for wr in self.data.values():
00158                 yield wr

Reimplemented from _abcoll.Mapping.

Definition at line 137 of file weakref.py.

00137 
00138     def keys(self):
00139         with _IterationGuard(self):
00140             for k, wr in self.data.items():
00141                 if wr() is not None:
00142                     yield k

def weakref.WeakValueDictionary.pop (   self,
  key,
  args 
)

Reimplemented from _abcoll.MutableMapping.

Definition at line 175 of file weakref.py.

00175 
00176     def pop(self, key, *args):
00177         if self._pending_removals:
00178             self._commit_removals()
00179         try:
00180             o = self.data.pop(key)()
00181         except KeyError:
00182             if args:
00183                 return args[0]
00184             raise
00185         if o is None:
00186             raise KeyError(key)
00187         else:
00188             return o

Here is the call graph for this function:

Reimplemented from _abcoll.MutableMapping.

Definition at line 166 of file weakref.py.

00166 
00167     def popitem(self):
00168         if self._pending_removals:
00169             self._commit_removals()
00170         while True:
00171             key, wr = self.data.popitem()
00172             o = wr()
00173             if o is not None:
00174                 return key, o

Here is the call graph for this function:

def abc.ABCMeta.register (   cls,
  subclass 
) [inherited]
Register a virtual subclass of an ABC.

Definition at line 135 of file abc.py.

00135 
00136     def register(cls, subclass):
00137         """Register a virtual subclass of an ABC."""
00138         if not isinstance(subclass, type):
00139             raise TypeError("Can only register classes")
00140         if issubclass(subclass, cls):
00141             return  # Already a subclass
00142         # Subtle: test for cycles *after* testing for "already a subclass";
00143         # this means we allow X.register(X) and interpret it as a no-op.
00144         if issubclass(cls, subclass):
00145             # This would create a cycle, which is bad for the algorithm below
00146             raise RuntimeError("Refusing to create an inheritance cycle")
00147         cls._abc_registry.add(subclass)
00148         ABCMeta._abc_invalidation_counter += 1  # Invalidate negative cache

Here is the caller graph for this function:

def abc.ABCMeta.register (   cls,
  subclass 
) [inherited]
Register a virtual subclass of an ABC.

Definition at line 135 of file abc.py.

00135 
00136     def register(cls, subclass):
00137         """Register a virtual subclass of an ABC."""
00138         if not isinstance(subclass, type):
00139             raise TypeError("Can only register classes")
00140         if issubclass(subclass, cls):
00141             return  # Already a subclass
00142         # Subtle: test for cycles *after* testing for "already a subclass";
00143         # this means we allow X.register(X) and interpret it as a no-op.
00144         if issubclass(cls, subclass):
00145             # This would create a cycle, which is bad for the algorithm below
00146             raise RuntimeError("Refusing to create an inheritance cycle")
00147         cls._abc_registry.add(subclass)
00148         ABCMeta._abc_invalidation_counter += 1  # Invalidate negative cache

Here is the caller graph for this function:

def abc.ABCMeta.register (   cls,
  subclass 
) [inherited]
Register a virtual subclass of an ABC.

Definition at line 135 of file abc.py.

00135 
00136     def register(cls, subclass):
00137         """Register a virtual subclass of an ABC."""
00138         if not isinstance(subclass, type):
00139             raise TypeError("Can only register classes")
00140         if issubclass(subclass, cls):
00141             return  # Already a subclass
00142         # Subtle: test for cycles *after* testing for "already a subclass";
00143         # this means we allow X.register(X) and interpret it as a no-op.
00144         if issubclass(cls, subclass):
00145             # This would create a cycle, which is bad for the algorithm below
00146             raise RuntimeError("Refusing to create an inheritance cycle")
00147         cls._abc_registry.add(subclass)
00148         ABCMeta._abc_invalidation_counter += 1  # Invalidate negative cache

Here is the caller graph for this function:

def weakref.WeakValueDictionary.setdefault (   self,
  key,
  default = None 
)

Reimplemented from _abcoll.MutableMapping.

Definition at line 189 of file weakref.py.

00189 
00190     def setdefault(self, key, default=None):
00191         try:
00192             wr = self.data[key]
00193         except KeyError:
00194             if self._pending_removals:
00195                 self._commit_removals()
00196             self.data[key] = KeyedRef(default, self._remove, key)
00197             return default
00198         else:
00199             return wr()

Here is the call graph for this function:

def weakref.WeakValueDictionary.update (   self,
  dict = None,
  kwargs 
)

Definition at line 200 of file weakref.py.

00200 
00201     def update(self, dict=None, **kwargs):
00202         if self._pending_removals:
00203             self._commit_removals()
00204         d = self.data
00205         if dict is not None:
00206             if not hasattr(dict, "items"):
00207                 dict = type({})(dict)
00208             for key, o in dict.items():
00209                 d[key] = KeyedRef(o, self._remove, key)
00210         if len(kwargs):
00211             self.update(kwargs)

Here is the call graph for this function:

Here is the caller graph for this function:

def _abcoll.MutableMapping.update (   args,
  kwds 
) [inherited]

Definition at line 493 of file _abcoll.py.

00493 
00494     def update(*args, **kwds):
00495         if len(args) > 2:
00496             raise TypeError("update() takes at most 2 positional "
00497                             "arguments ({} given)".format(len(args)))
00498         elif not args:
00499             raise TypeError("update() takes at least 1 argument (0 given)")
00500         self = args[0]
00501         other = args[1] if len(args) >= 2 else ()
00502 
00503         if isinstance(other, Mapping):
00504             for key in other:
00505                 self[key] = other[key]
00506         elif hasattr(other, "keys"):
00507             for key in other.keys():
00508                 self[key] = other[key]
00509         else:
00510             for key, value in other:
00511                 self[key] = value
00512         for key, value in kwds.items():
00513             self[key] = value

Here is the caller graph for this function:

Return a list of weak references to the values.

The references are not guaranteed to be 'live' at the time
they are used, so the result of calling the references needs
to be checked before being used.  This can be used to avoid
creating references that will cause the garbage collector to
keep the values around longer than needed.

Definition at line 212 of file weakref.py.

00212 
00213     def valuerefs(self):
00214         """Return a list of weak references to the values.
00215 
00216         The references are not guaranteed to be 'live' at the time
00217         they are used, so the result of calling the references needs
00218         to be checked before being used.  This can be used to avoid
00219         creating references that will cause the garbage collector to
00220         keep the values around longer than needed.
00221 
00222         """
00223         return list(self.data.values())
00224 

Reimplemented from _abcoll.Mapping.

Definition at line 159 of file weakref.py.

00159 
00160     def values(self):
00161         with _IterationGuard(self):
00162             for wr in self.data.values():
00163                 obj = wr()
00164                 if obj is not None:
00165                     yield obj

Here is the caller graph for this function:


Member Data Documentation

Definition at line 106 of file weakref.py.

Definition at line 143 of file weakref.py.

Definition at line 56 of file weakref.py.

Definition at line 55 of file weakref.py.

Definition at line 53 of file weakref.py.

Definition at line 57 of file weakref.py.


The documentation for this class was generated from the following file: