From 2682e4cb48e306d38d64f87a457e2318be2bf875 Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Sun, 17 May 2020 21:09:00 +0200 Subject: [PATCH] Seen, ChannelUserDictionary: Internalize channel names. They are not many of them, but they are used a lot so they take up a surprising amount of memory. --- plugins/Seen/plugin.py | 1 + plugins/__init__.py | 3 +++ 2 files changed, 4 insertions(+) diff --git a/plugins/Seen/plugin.py b/plugins/Seen/plugin.py index ffb3ca32d..4b736b272 100644 --- a/plugins/Seen/plugin.py +++ b/plugins/Seen/plugin.py @@ -65,6 +65,7 @@ class SeenDB(plugins.ChannelUserDB): def update(self, channel, nickOrId, saying): seen = time.time() + channel = sys.intern(channel) self[channel, nickOrId] = (seen, saying) self[channel, ''] = (seen, saying) diff --git a/plugins/__init__.py b/plugins/__init__.py index aec351704..cde2ef482 100644 --- a/plugins/__init__.py +++ b/plugins/__init__.py @@ -31,6 +31,7 @@ import gc import os import csv +import sys import time import codecs import string @@ -188,6 +189,7 @@ class ChannelUserDictionary(collections.abc.MutableMapping): def __setitem__(self, key, v): (channel, id) = key + channel = sys.intern(channel) if channel not in self.channels: self.channels[channel] = self.IdDict() self.channels[channel][id] = v @@ -242,6 +244,7 @@ class ChannelUserDB(ChannelUserDictionary): except ValueError: # We'll skip over this so, say, nicks can be kept here. pass + channel = sys.intern(channel) v = self.deserialize(channel, id, t) self[channel, id] = v except Exception as e: