170 Commits

Author SHA1 Message Date
Steven Berler
10b0b62f50 performance improvements
Replaced server member lists, channel lists, and private channel lists
with dicts. This allows O(1) lookups and removes (previously it would be
an O(N) operation to lookup or remove). I did pretty extensive testing
and benchmarking to compare the performance of using lists vs using
dicts. Iterating through lists to find an item is only faster in the
average case for extremely small lists (less than 3 items). For 100
items, using a dict is about 10 times faster on average (and about 100
times faster for 1000 items). The overhead in dicts is in memory usage
and initial creation time. Creating and populating a dict is about 2 to
3 times slower than creating and appending items to a list. However this
cost is still tiny.  For 1000 items this equates to about a 70
microsecond difference (on an i7 CPU) for populating the entire dict.
The memory overhead for a dict (compared to a list) is about 25-60 KB
per 1000 items (can vary depending on dict resizing).

Originally I wanted to use OrderedDicts to presereve order, but in my
testing OrderedDicts have about 6x the memory overhead compared to
normal dicts.
2016-01-08 13:24:55 -05:00
Rapptz
a2b97ae2db Fix handling of embed-only MESSAGE_UPDATE. 2016-01-07 02:54:01 -05:00
Rapptz
0fbb58cde9 Change the way MESSAGE_UPDATE events are handled.
Previously we created a copy of the object and did some strange
iteration over the data and set the attributes that we thought
were valid. This worked back then in v0.1.0 of the library when
it was written, but it no longer works nowadays when we want to
be as future proof as possible.
2016-01-07 01:27:38 -05:00
Rapptz
c1583dd7d6 Unavailable guilds get added to cache. 2016-01-06 12:57:09 -05:00
Rapptz
db4cc791dd Update license of files to 2016. 2016-01-04 22:28:29 -05:00
Rapptz
c11bd9b8f4 ConnectionState is now constructed in Client.__init__.
This should reduce the amount of checks for None if someone doesn't
want a websocket connection. The connection state is instead cleared
rather than reconstructed.
2015-12-29 11:59:18 -05:00
Khazhismel
0aa46e6def Add game data class, replace game_id. 2015-12-23 21:28:18 -05:00
Rapptz
7258a9e700 Delete messages from message cache when you leave the server. 2015-12-19 10:36:11 -05:00
Rapptz
f1f0e169e4 Add __slots__ where appropriate to data classes. 2015-12-19 06:18:12 -05:00
Rapptz
9075d46efd Add on_member_ban and on_member_unban events.
Fixes #58.
2015-12-17 18:22:16 -05:00
Rapptz
63565026c4 Remove on_status event. Superseded by on_member_update. 2015-12-17 06:18:08 -05:00
Rapptz
49d78c69c7 All update related events now pass in the previous state. 2015-12-17 06:05:35 -05:00
Rapptz
4f66d41ca3 Add Server.me attribute to access the Member version of Client.user. 2015-12-16 23:35:05 -05:00
Rapptz
de1c74a399 Make more things into properties.
A lot of the expensive getters were transformed into cached properties
instead. A lot of things that were properties were transformed into
properties as well.
2015-12-16 22:03:16 -05:00
Rapptz
7f0a048299 Fix GUILD_ROLE_DELETE triggering ValueError. 2015-12-14 23:26:22 -05:00
Steven Berler
037da750dd avoid potential bug when creating new private msgs
It probably isn't good to rely on an item that was added to a list to
still be the last item, especially if we could have other async
coroutines modify the list. This may not be an actual issue, but having
the function explicitly return the object that it just added to the list
should guarantee that we don't accidentally pull the wrong item from the
end of the list later.
2015-12-13 13:01:05 -05:00
Rapptz
cfc26b894f Fix issue with member.roles being empty. 2015-12-08 00:46:58 -05:00
Rapptz
80b32e769e Handle GUILD_UPDATE 2015-12-06 03:09:55 -05:00
Rapptz
79bdf2a721 Add enumerators instead of strings.
Changes channel type, status and server region into 3.4 enums.
2015-12-04 22:13:17 -05:00
Rapptz
f197c34583 Begin working on asyncio port. 2015-12-04 00:16:34 -05:00