put a cachetools LRUCache on casefold()

This commit is contained in:
jesopo 2022-01-07 11:27:01 +00:00
parent 1e187db35f
commit e3884c7505
2 changed files with 6 additions and 3 deletions

View File

@ -1,5 +1,6 @@
import string
from typing import List
from cachetools import cached, LRUCache
ASCII_UPPER = list(string.ascii_uppercase)
ASCII_LOWER = list(string.ascii_lowercase)
@ -15,6 +16,7 @@ def _replace(s: str, upper: List[str], lower: List[str]):
out += char
return out
@cached(cache=LRUCache(maxsize=1024))
def casefold(mapping: str, s: str):
if mapping == "rfc1459":
return _replace(s, RFC1459_UPPER, RFC1459_LOWER)

View File

@ -1,3 +1,4 @@
freezegun ~=1.1.0
irctokens ~=2.0.0
pendulum ~=2.1.0
cachetools ~=5.0.0
freezegun ~=1.1.0
irctokens ~=2.0.0
pendulum ~=2.1.0