本文整理汇总了Python中_weakrefset._IterationGuard方法的典型用法代码示例。如果您正苦于以下问题:Python _weakrefset._IterationGuard方法的具体用法?Python _weakrefset._IterationGuard怎么用?Python _weakrefset._IterationGuard使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类_weakrefset
的用法示例。
在下文中一共展示了_weakrefset._IterationGuard方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: items
# 需要导入模块: import _weakrefset [as 别名]
# 或者: from _weakrefset import _IterationGuard [as 别名]
def items(self):
with _IterationGuard(self):
for k, wr in self.data.items():
v = wr()
if v is not None:
yield k, v
示例2: keys
# 需要导入模块: import _weakrefset [as 别名]
# 或者: from _weakrefset import _IterationGuard [as 别名]
def keys(self):
with _IterationGuard(self):
for k, wr in self.data.items():
if wr() is not None:
yield k
示例3: itervaluerefs
# 需要导入模块: import _weakrefset [as 别名]
# 或者: from _weakrefset import _IterationGuard [as 别名]
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.
"""
with _IterationGuard(self):
for wr in self.data.values():
yield wr
示例4: values
# 需要导入模块: import _weakrefset [as 别名]
# 或者: from _weakrefset import _IterationGuard [as 别名]
def values(self):
with _IterationGuard(self):
for wr in self.data.values():
obj = wr()
if obj is not None:
yield obj
示例5: iteritems
# 需要导入模块: import _weakrefset [as 别名]
# 或者: from _weakrefset import _IterationGuard [as 别名]
def iteritems(self):
if self._pending_removals:
self._commit_removals()
with _IterationGuard(self):
for wr in self.data.itervalues():
value = wr()
if value is not None:
yield wr.key, value
示例6: iterkeys
# 需要导入模块: import _weakrefset [as 别名]
# 或者: from _weakrefset import _IterationGuard [as 别名]
def iterkeys(self):
if self._pending_removals:
self._commit_removals()
with _IterationGuard(self):
for k in self.data.iterkeys():
yield k
示例7: itervaluerefs
# 需要导入模块: import _weakrefset [as 别名]
# 或者: from _weakrefset import _IterationGuard [as 别名]
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):
for wr in self.data.itervalues():
yield wr
示例8: itervalues
# 需要导入模块: import _weakrefset [as 别名]
# 或者: from _weakrefset import _IterationGuard [as 别名]
def itervalues(self):
if self._pending_removals:
self._commit_removals()
with _IterationGuard(self):
for wr in self.data.itervalues():
obj = wr()
if obj is not None:
yield obj
示例9: itervaluerefs
# 需要导入模块: import _weakrefset [as 别名]
# 或者: from _weakrefset import _IterationGuard [as 别名]
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.
"""
with _IterationGuard(self):
yield from self.data.values()
示例10: iteritems
# 需要导入模块: import _weakrefset [as 别名]
# 或者: from _weakrefset import _IterationGuard [as 别名]
def iteritems(self):
with _IterationGuard(self):
for wr in self.data.itervalues():
value = wr()
if value is not None:
yield wr.key, value
示例11: iterkeys
# 需要导入模块: import _weakrefset [as 别名]
# 或者: from _weakrefset import _IterationGuard [as 别名]
def iterkeys(self):
with _IterationGuard(self):
for k in self.data.iterkeys():
yield k
示例12: itervaluerefs
# 需要导入模块: import _weakrefset [as 别名]
# 或者: from _weakrefset import _IterationGuard [as 别名]
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.
"""
with _IterationGuard(self):
for wr in self.data.itervalues():
yield wr
示例13: itervalues
# 需要导入模块: import _weakrefset [as 别名]
# 或者: from _weakrefset import _IterationGuard [as 别名]
def itervalues(self):
with _IterationGuard(self):
for wr in self.data.itervalues():
obj = wr()
if obj is not None:
yield obj
示例14: items
# 需要导入模块: import _weakrefset [as 别名]
# 或者: from _weakrefset import _IterationGuard [as 别名]
def items(self):
if self._pending_removals:
self._commit_removals()
with _IterationGuard(self):
for k, wr in self.data.items():
v = wr()
if v is not None:
yield k, v
示例15: keys
# 需要导入模块: import _weakrefset [as 别名]
# 或者: from _weakrefset import _IterationGuard [as 别名]
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