self.minlen) def __bool__(self): # type: () -> bool return bool(self._data) __nonzero__ = __bool__ # Py2 @property def _heap_overload(self): # type: () -> float """Compute how much is heap bigger than data [percents].""" return len(self._heap) * 100 / max(len(self._data), 1) - 100 MutableSet.register(LimitedSet) # noqa: E305 class Evictable(object): """Mixin for classes supporting the ``evict`` method.""" Empty = Empty def evict(self): # type: () -> None """Force evict until maxsize is enforced.""" self._evict(range=count) def _evict(self, limit=100, range=range): # type: (int) -> None try:
self.minlen) def __bool__(self): # type: () -> bool return bool(self._data) __nonzero__ = __bool__ # Py2 @property def _heap_overload(self): # type: () -> float """Compute how much is heap bigger than data [percents].""" return len(self._heap) * 100 / max(len(self._data), 1) - 100 MutableSet.register(LimitedSet) class Evictable: """Mixin for classes supporting the ``evict`` method.""" Empty = Empty def evict(self) -> None: """Force evict until maxsize is enforced.""" self._evict(range=count) def _evict(self, limit: int = 100, range=range) -> None: try: [self._evict1() for _ in range(limit)] except IndexError:
return self.__class__, ( self.maxlen, self.expires, self.as_dict(), self.minlen) def __bool__(self): # type: () -> bool return bool(self._data) __nonzero__ = __bool__ # Py2 @property def _heap_overload(self): # type: () -> float """Compute how much is heap bigger than data [percents].""" return len(self._heap) * 100 / max(len(self._data), 1) - 100 MutableSet.register(LimitedSet) # noqa: E305 class Evictable(object): """Mixin for classes supporting the ``evict`` method.""" Empty = Empty def evict(self): # type: () -> None """Force evict until maxsize is enforced.""" self._evict(range=count) def _evict(self, limit=100, range=range): # type: (int) -> None try:
diff = other - self if len(diff) == M - N: # assert self <= other return diff # N*log2(M) v.s. N+M M_N = M + N log2_N = N.bit_length() N_log2_M = N * log2_M if N_log2_M <= M_N: it1 = (x for x in self if x not in other) it2 = (x for x in self if x not in other) else: key = Node.entity2key it = symmetric_difference_of_two_sorted_iterables( self, other, left_key=key, right_key=key, __lt__=Node.key_lt) cls = type(self) output = cls.from_sorted_entities(it) return output MutableSet.register(OrderedSet) if __name__ == "__main__": print('\n'.join(dir(OrderedSet))) print() import doctest doctest.testmod()