Added __slots__ to IrcDict and IrcSet for optimization purposes.

This commit is contained in:
Jeremy Fincher 2003-09-23 15:53:04 +00:00
parent 7081d64124
commit 6084d00067

View File

@ -334,6 +334,7 @@ class IrcString(str):
class IrcDict(dict): class IrcDict(dict):
"""Subclass of dict to make key comparison IRC-case insensitive.""" """Subclass of dict to make key comparison IRC-case insensitive."""
__slots__ = ()
def __contains__(self, s): def __contains__(self, s):
return dict.__contains__(self, IrcString(s)) return dict.__contains__(self, IrcString(s))
has_key = __contains__ has_key = __contains__
@ -348,6 +349,7 @@ class IrcDict(dict):
dict.__delitem__(self, IrcString(s)) dict.__delitem__(self, IrcString(s))
class IrcSet(sets.Set): class IrcSet(sets.Set):
__slots__ = ()
def add(self, s): def add(self, s):
return sets.Set.add(self, IrcString(s)) return sets.Set.add(self, IrcString(s))