Python _weakref.ref() Examples
The following are 30
code examples of _weakref.ref().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
_weakref
, or try the search function
.
Example #1
Source File: _weakrefset.py From BinderFilter with MIT License | 5 votes |
def add(self, item): if self._pending_removals: self._commit_removals() self.data.add(ref(item, self._remove))
Example #2
Source File: _weakrefset.py From Safejumper-for-Desktop with GNU General Public License v2.0 | 5 votes |
def __init__(self, weakcontainer): # Don't create cycles self.weakcontainer = ref(weakcontainer)
Example #3
Source File: _weakrefset.py From oss-ftp with MIT License | 5 votes |
def __iand__(self, other): if self._pending_removals: self._commit_removals() self.data.intersection_update(ref(item) for item in other) return self
Example #4
Source File: _weakrefset.py From Safejumper-for-Desktop with GNU General Public License v2.0 | 5 votes |
def __contains__(self, item): try: wr = ref(item) except TypeError: return False return wr in self.data
Example #5
Source File: _weakrefset.py From Safejumper-for-Desktop with GNU General Public License v2.0 | 5 votes |
def add(self, item): if self._pending_removals: self._commit_removals() self.data.add(ref(item, self._remove))
Example #6
Source File: _weakrefset.py From Safejumper-for-Desktop with GNU General Public License v2.0 | 5 votes |
def __init__(self, data=None): self.data = set() def _remove(item, selfref=ref(self)): self = selfref() if self is not None: if self._iterating: self._pending_removals.append(item) else: self.data.discard(item) self._remove = _remove # A list of keys to be removed self._pending_removals = [] self._iterating = set() if data is not None: self.update(data)
Example #7
Source File: _weakrefset.py From oss-ftp with MIT License | 5 votes |
def __eq__(self, other): if not isinstance(other, self.__class__): return NotImplemented return self.data == set(ref(item) for item in other)
Example #8
Source File: _weakrefset.py From oss-ftp with MIT License | 5 votes |
def issuperset(self, other): return self.data.issuperset(ref(item) for item in other)
Example #9
Source File: _weakrefset.py From oss-ftp with MIT License | 5 votes |
def __lt__(self, other): return self.data < set(ref(item) for item in other)
Example #10
Source File: _weakrefset.py From oss-ftp with MIT License | 5 votes |
def issubset(self, other): return self.data.issubset(ref(item) for item in other)
Example #11
Source File: _weakrefset.py From oss-ftp with MIT License | 5 votes |
def __ixor__(self, other): if self._pending_removals: self._commit_removals() if self is other: self.data.clear() else: self.data.symmetric_difference_update(ref(item, self._remove) for item in other) return self
Example #12
Source File: _weakrefset.py From BinderFilter with MIT License | 5 votes |
def issubset(self, other): return self.data.issubset(ref(item) for item in other)
Example #13
Source File: _weakrefset.py From BinderFilter with MIT License | 5 votes |
def __iand__(self, other): if self._pending_removals: self._commit_removals() self.data.intersection_update(ref(item) for item in other) return self
Example #14
Source File: _weakrefset.py From BinderFilter with MIT License | 5 votes |
def __isub__(self, other): if self._pending_removals: self._commit_removals() if self is other: self.data.clear() else: self.data.difference_update(ref(item) for item in other) return self
Example #15
Source File: _weakrefset.py From BinderFilter with MIT License | 5 votes |
def remove(self, item): if self._pending_removals: self._commit_removals() self.data.remove(ref(item))
Example #16
Source File: _weakrefset.py From BinderFilter with MIT License | 5 votes |
def __lt__(self, other): return self.data < set(ref(item) for item in other)
Example #17
Source File: _weakrefset.py From BinderFilter with MIT License | 5 votes |
def __contains__(self, item): try: wr = ref(item) except TypeError: return False return wr in self.data
Example #18
Source File: _weakrefset.py From BinderFilter with MIT License | 5 votes |
def __init__(self, data=None): self.data = set() def _remove(item, selfref=ref(self)): self = selfref() if self is not None: if self._iterating: self._pending_removals.append(item) else: self.data.discard(item) self._remove = _remove # A list of keys to be removed self._pending_removals = [] self._iterating = set() if data is not None: self.update(data)
Example #19
Source File: _weakrefset.py From BinderFilter with MIT License | 5 votes |
def __init__(self, weakcontainer): # Don't create cycles self.weakcontainer = ref(weakcontainer)
Example #20
Source File: _weakrefset.py From kobo-predict with BSD 2-Clause "Simplified" License | 5 votes |
def __ixor__(self, other): if self._pending_removals: self._commit_removals() if self is other: self.data.clear() else: self.data.symmetric_difference_update(ref(item, self._remove) for item in other) return self
Example #21
Source File: _weakrefset.py From kobo-predict with BSD 2-Clause "Simplified" License | 5 votes |
def __eq__(self, other): if not isinstance(other, self.__class__): return NotImplemented return self.data == set(ref(item) for item in other)
Example #22
Source File: _weakrefset.py From kobo-predict with BSD 2-Clause "Simplified" License | 5 votes |
def issuperset(self, other): return self.data.issuperset(ref(item) for item in other)
Example #23
Source File: _weakrefset.py From kobo-predict with BSD 2-Clause "Simplified" License | 5 votes |
def __lt__(self, other): return self.data < set(ref(item) for item in other)
Example #24
Source File: _weakrefset.py From kobo-predict with BSD 2-Clause "Simplified" License | 5 votes |
def issubset(self, other): return self.data.issubset(ref(item) for item in other)
Example #25
Source File: _weakrefset.py From kobo-predict with BSD 2-Clause "Simplified" License | 5 votes |
def __iand__(self, other): if self._pending_removals: self._commit_removals() self.data.intersection_update(ref(item) for item in other) return self
Example #26
Source File: _weakrefset.py From kobo-predict with BSD 2-Clause "Simplified" License | 5 votes |
def __isub__(self, other): if self._pending_removals: self._commit_removals() if self is other: self.data.clear() else: self.data.difference_update(ref(item) for item in other) return self
Example #27
Source File: _weakrefset.py From kobo-predict with BSD 2-Clause "Simplified" License | 5 votes |
def remove(self, item): if self._pending_removals: self._commit_removals() self.data.remove(ref(item))
Example #28
Source File: _weakrefset.py From kobo-predict with BSD 2-Clause "Simplified" License | 5 votes |
def add(self, item): if self._pending_removals: self._commit_removals() self.data.add(ref(item, self._remove))
Example #29
Source File: _weakrefset.py From kobo-predict with BSD 2-Clause "Simplified" License | 5 votes |
def __contains__(self, item): try: wr = ref(item) except TypeError: return False return wr in self.data
Example #30
Source File: _weakrefset.py From kobo-predict with BSD 2-Clause "Simplified" License | 5 votes |
def __init__(self, data=None): self.data = set() def _remove(item, selfref=ref(self)): self = selfref() if self is not None: if self._iterating: self._pending_removals.append(item) else: self.data.discard(item) self._remove = _remove # A list of keys to be removed self._pending_removals = [] self._iterating = set() if data is not None: self.update(data)