From 0e8bfecf37784ec92a4a7436699f215807944142 Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Wed, 2 Dec 2015 12:21:46 +0100 Subject: [PATCH] utils.structures: Define __slots__ for more classes. --- src/utils/structures.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/utils/structures.py b/src/utils/structures.py index efe7483ec..f5c12fcd5 100644 --- a/src/utils/structures.py +++ b/src/utils/structures.py @@ -306,6 +306,7 @@ class smallqueue(list): class TimeoutQueue(object): + __slots__ = ('queue', 'timeout') def __init__(self, timeout, queue=None): if queue is None: queue = smallqueue() @@ -402,6 +403,7 @@ class TwoWayDictionary(dict): class MultiSet(object): + __slots__ = ('d',) def __init__(self, seq=()): self.d = {} for elt in seq: @@ -426,6 +428,7 @@ class MultiSet(object): class CacheDict(collections.MutableMapping): + __slots__ = ('d', 'max') def __init__(self, max, **kwargs): self.d = dict(**kwargs) self.max = max @@ -456,6 +459,7 @@ class CacheDict(collections.MutableMapping): class TruncatableSet(collections.MutableSet): """A set that keeps track of the order of inserted elements so the oldest can be removed.""" + __slots__ = ('_ordered_items', '_items') def __init__(self, iterable=[]): self._ordered_items = list(iterable) self._items = set(self._ordered_items)