diff options
| author | Rapptz <[email protected]> | 2017-05-18 05:15:06 -0400 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2017-05-18 05:15:06 -0400 |
| commit | 852699500453ea9565ec5d678e99a49bf64c2395 (patch) | |
| tree | 188b7a19a7565ea49500943b5e43a369542a0891 /discord/member.py | |
| parent | Fix User == Member comparisons. (diff) | |
| download | discord.py-852699500453ea9565ec5d678e99a49bf64c2395.tar.xz discord.py-852699500453ea9565ec5d678e99a49bf64c2395.zip | |
Minor speedup when doing comparisons.
Shred 2 getattr calls + 1 global lookup to 1 global lookup.
Diffstat (limited to 'discord/member.py')
| -rw-r--r-- | discord/member.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/discord/member.py b/discord/member.py index 7e4c4069..a91f60d1 100644 --- a/discord/member.py +++ b/discord/member.py @@ -106,8 +106,10 @@ def flatten_user(cls): return cls +_BaseUser = discord.abc.User + @flatten_user -class Member(discord.abc.Messageable, discord.abc.User): +class Member(discord.abc.Messageable, _BaseUser): """Represents a Discord member to a :class:`Guild`. This implements a lot of the functionality of :class:`User`. @@ -170,7 +172,7 @@ class Member(discord.abc.Messageable, discord.abc.User): ' bot={1.bot} nick={0.nick!r} guild={0.guild!r}>'.format(self, self._user) def __eq__(self, other): - return isinstance(other, discord.abc.User) and other.id == self.id + return isinstance(other, _BaseUser) and other.id == self.id def __ne__(self, other): return not self.__eq__(other) |