Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tools.target: use slots for Channel and User types
This can save some significant memory when Sopel is in many and/or large channels. For example, without this patch (in bytes): - Size of empty channel: 1200 - Size of channel with 100 users: 84560 - Size of channel with 1000 users: 817944 And with this patch (also in bytes): - Size of empty channel: 680 - Size of channel with 100 users: 72608 - Size of channel with 1000 users: 705304 An empty channel is reduced by nearly half, and channels with some significant user count can be reduced by some 10-15%. These values were calculated using `Pympler.asizeof.asizeof()`, in a simple test script: from sopel.tools import Identifier, target from pympler.asizeof import asizeof c = target.Channel(Identifier('#Sopel')) print('Size of empty channel:', asizeof(c)) for n in range(1, 100): name = 'user{}'.format(n) c.add_user( target.User( Identifier(name) name, 'some.example.org' ) ) print('Size of channel with 100 users:', asizeof(c)) for n in range(101, 1000): name = 'user{}'.format(n) c.add_user( target.User( Identifier(name), name, 'some.example.org' ) ) print('Size of channel with 1000 users:', asizeof(c))
- Loading branch information