From 68cf5d8eb9721cb1d91ba004409b82b0a283782d Mon Sep 17 00:00:00 2001 From: Matteo Date: Tue, 18 Feb 2020 17:48:53 +0100 Subject: Use pregenerated partials This avoid recreating partials for each re-eval --- bot/cogs/snekbox.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/bot/cogs/snekbox.py b/bot/cogs/snekbox.py index 3fc8d9937..d075c4fd5 100644 --- a/bot/cogs/snekbox.py +++ b/bot/cogs/snekbox.py @@ -203,6 +203,9 @@ class Snekbox(Cog): log.info(f"Received code from {ctx.author} for evaluation:\n{code}") + _predicate_eval_message_edit = partial(predicate_eval_message_edit, ctx) + _predicate_emoji_reaction = partial(predicate_eval_emoji_reaction, ctx) + while True: self.jobs[ctx.author.id] = datetime.datetime.now() code = self.prepare_input(code) @@ -234,13 +237,13 @@ class Snekbox(Cog): try: _, new_message = await self.bot.wait_for( 'message_edit', - check=partial(predicate_eval_message_edit, ctx), + check=_predicate_eval_message_edit, timeout=10 ) await ctx.message.add_reaction('🔁') await self.bot.wait_for( 'reaction_add', - check=partial(predicate_eval_emoji_reaction, ctx), + check=_predicate_emoji_reaction, timeout=10 ) -- cgit v1.2.3