mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-12 05:02:32 +01:00
utils.gen: set __slots__.
We create *a lot* of these structs, so it saves a considerable amount of space.
This commit is contained in:
parent
0bfd82f650
commit
eead5566e5
@ -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
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user