From 338c41abd58093a38429f23875940fc72f253184 Mon Sep 17 00:00:00 2001 From: yanyongyu Date: Sat, 1 Jan 2022 16:43:48 +0800 Subject: [PATCH] :zap: improve const performance --- nonebot/consts.py | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/nonebot/consts.py b/nonebot/consts.py index 11e3feaa..5f6fa52b 100644 --- a/nonebot/consts.py +++ b/nonebot/consts.py @@ -1,20 +1,22 @@ +from sys import intern + # used by Matcher -RECEIVE_KEY = "_receive_{id}" -LAST_RECEIVE_KEY = "_last_receive" -ARG_KEY = "{key}" -REJECT_TARGET = "_current_target" -REJECT_CACHE_TARGET = "_next_target" +RECEIVE_KEY = intern("_receive_{id}") +LAST_RECEIVE_KEY = intern("_last_receive") +ARG_KEY = intern("{key}") +REJECT_TARGET = intern("_current_target") +REJECT_CACHE_TARGET = intern("_next_target") # used by Rule -PREFIX_KEY = "_prefix" +PREFIX_KEY = intern("_prefix") -CMD_KEY = "command" -RAW_CMD_KEY = "raw_command" -CMD_ARG_KEY = "command_arg" +CMD_KEY = intern("command") +RAW_CMD_KEY = intern("raw_command") +CMD_ARG_KEY = intern("command_arg") -SHELL_ARGS = "_args" -SHELL_ARGV = "_argv" +SHELL_ARGS = intern("_args") +SHELL_ARGV = intern("_argv") -REGEX_MATCHED = "_matched" -REGEX_GROUP = "_matched_groups" -REGEX_DICT = "_matched_dict" +REGEX_MATCHED = intern("_matched") +REGEX_GROUP = intern("_matched_groups") +REGEX_DICT = intern("_matched_dict")