From eead5566e5215d97f882e0e11e61da5410ff1ce2 Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Fri, 15 May 2020 22:57:35 +0200 Subject: [PATCH] utils.gen: set __slots__. We create *a lot* of these structs, so it saves a considerable amount of space. --- src/ircdb.py | 2 +- src/utils/gen.py | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ircdb.py b/src/ircdb.py index 82434e92b..e09ad482f 100644 --- a/src/ircdb.py +++ b/src/ircdb.py @@ -688,7 +688,7 @@ class DuplicateHostmask(ValueError): class UsersDictionary(utils.IterableMap): """A simple serialized-to-file User Database.""" __slots__ = ('noFlush', 'filename', 'users', '_nameCache', - '_hostmaskCache') + '_hostmaskCache', 'nextId') def __init__(self): self.noFlush = False self.filename = None diff --git a/src/utils/gen.py b/src/utils/gen.py index bcabb6e4e..e32112b78 100644 --- a/src/utils/gen.py +++ b/src/utils/gen.py @@ -219,6 +219,7 @@ def exnToString(e): class IterableMap(object): """Define .items() in a class and subclass this to get the other iters. """ + __slots__ = () def items(self): if minisix.PY3 and hasattr(self, 'iteritems'): # For old plugins @@ -252,6 +253,7 @@ class IterableMap(object): class InsensitivePreservingDict(collections.abc.MutableMapping): + __slots__ = ('data',) def key(self, s): """Override this if you wish.""" if s is not None: @@ -307,6 +309,7 @@ class InsensitivePreservingDict(collections.abc.MutableMapping): class NormalizingSet(set): + __slots__ = () def __init__(self, iterable=()): iterable = list(map(self.normalize, iterable)) super(NormalizingSet, self).__init__(iterable)