aboutsummaryrefslogtreecommitdiff
path: root/discord/client.py
diff options
context:
space:
mode:
authorRapptz <[email protected]>2018-09-24 23:22:49 -0400
committerRapptz <[email protected]>2018-09-24 23:22:49 -0400
commit27216892547bb073777056379d549a6dc42872cb (patch)
tree18d1eded01727f64c93e31d23cb68201de16c832 /discord/client.py
parentOptimise some member and user related routines. (diff)
downloaddiscord.py-27216892547bb073777056379d549a6dc42872cb.tar.xz
discord.py-27216892547bb073777056379d549a6dc42872cb.zip
Optimise tight loops in DiscordGateway.received_message
* type(x) is y is faster than isinstance(x, y) * Re-arrange if-statements for common statements * Drop handler getattr for most events that don't use it
Diffstat (limited to 'discord/client.py')
-rw-r--r--discord/client.py13
1 files changed, 5 insertions, 8 deletions
diff --git a/discord/client.py b/discord/client.py
index 31b2a5a1..23907574 100644
--- a/discord/client.py
+++ b/discord/client.py
@@ -125,7 +125,11 @@ class Client:
proxy_auth = options.pop('proxy_auth', None)
self.http = HTTPClient(connector, proxy=proxy, proxy_auth=proxy_auth, loop=self.loop)
- self._connection = ConnectionState(dispatch=self.dispatch, chunker=self._chunker,
+ self._handlers = {
+ 'ready': self._handle_ready
+ }
+
+ self._connection = ConnectionState(dispatch=self.dispatch, chunker=self._chunker, handlers=self._handlers,
syncer=self._syncer, http=self.http, loop=self.loop, **options)
self._connection.shard_count = self.shard_count
@@ -262,13 +266,6 @@ class Client:
del listeners[idx]
try:
- actual_handler = getattr(self, handler)
- except AttributeError:
- pass
- else:
- actual_handler(*args, **kwargs)
-
- try:
coro = getattr(self, method)
except AttributeError:
pass