diff options
| author | Rapptz <[email protected]> | 2019-05-29 01:22:36 -0400 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2019-05-29 01:22:53 -0400 |
| commit | 00a0856cc44549a29d5123b997db3a5e593f0896 (patch) | |
| tree | 48071f9464b906b2a39470e31a5013791f8c4da9 /discord/shard.py | |
| parent | Speed-up utils.get for the common cases (diff) | |
| download | discord.py-00a0856cc44549a29d5123b997db3a5e593f0896.tar.xz discord.py-00a0856cc44549a29d5123b997db3a5e593f0896.zip | |
Use a dict instead of getattr for parsing events.
Probably not a significant difference but might as well use it here.
The basic idea is to cache the getattr calls instead of repeatedly
doing it (since they're around 105ns on my machine). The dictionary
lookup is about 41ns on my machine.
The next step in speeding up library code some more should be in
the parser bodies themselves but that's a problem to tackle another
day.
Diffstat (limited to 'discord/shard.py')
| -rw-r--r-- | discord/shard.py | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/discord/shard.py b/discord/shard.py index a5f5f541..331d174b 100644 --- a/discord/shard.py +++ b/discord/shard.py @@ -221,6 +221,7 @@ class AutoShardedClient(Client): ws.token = self.http.token ws._connection = self._connection + ws._discord_parsers = self._connection.parsers ws._dispatch = self.dispatch ws.gateway = gateway ws.shard_id = shard_id |