From 1b9e3e4e2cc11be5729a1f6975b7cc95a73a1052 Mon Sep 17 00:00:00 2001 From: Rongrong Date: Sun, 3 Dec 2023 00:20:31 +0800 Subject: [PATCH] perf(*): speed up entry hashing with isal Signed-off-by: Rongrong --- requirements.txt | 1 + src/command/inner/utils.py | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index c1fff74899..a47968d4d9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -38,3 +38,4 @@ cachetools==5.3.2 CJKwrap==2.2 typing-extensions==4.8.0 uvloop==0.19.0; sys_platform!='win32' and sys_platform!='cygwin' and sys_platform!='cli' +isal==1.5.3; platform_machine=='x86_64' or platform_machine=='AMD64' or platform_machine=='aarch64' diff --git a/src/command/inner/utils.py b/src/command/inner/utils.py index 3e4acdfb35..cbd9f94f39 100644 --- a/src/command/inner/utils.py +++ b/src/command/inner/utils.py @@ -7,10 +7,14 @@ from itertools import chain, repeat from datetime import datetime from email.utils import parsedate_to_datetime -from zlib import crc32 from telethon import Button from telethon.tl.types import KeyboardButtonCallback +try: + from isal.isal_zlib import crc32 +except ImportError: + from zlib import crc32 + from ... import db, log, env from ...i18n import i18n