Exemplo n.º 1
0
 def keys(self):
     if self._pending_removals:
         self._commit_removals()
     with _IterationGuard(self):
         for k, wr in self.data.items():
             if wr() is not None:
                 yield k
Exemplo n.º 2
0
 def values(self):
     if self._pending_removals:
         self._commit_removals()
     with _IterationGuard(self):
         for wr in self.data.values():
             obj = wr()
             if obj is not None:
                 yield obj
Exemplo n.º 3
0
    def itervaluerefs(self):
        """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.

        """
        if self._pending_removals:
            self._commit_removals()
        with _IterationGuard(self):
            yield from self.data.values()
Exemplo n.º 4
0
 def values(self):
     with _IterationGuard(self):
         for wr, value in self.data.items():
             if wr() is not None:
                 yield value
Exemplo n.º 5
0
 def keys(self):
     with _IterationGuard(self):
         for wr in self.data:
             obj = wr()
             if obj is not None:
                 yield obj
Exemplo n.º 6
0
 def items(self):
     with _IterationGuard(self):
         for wr, value in self.data.items():
             key = wr()
             if key is not None:
                 yield key, value