Skip to content

Commit 87e4a39

Browse files
authored
Cache get_emoji_regex (#13)
In tests, this sped up creation of emoji strings by 75%.
1 parent f255654 commit 87e4a39

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

emoji_data_python/replacement.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import re
2+
from functools import cache
23
from typing import cast
34

45

@@ -38,6 +39,7 @@ def emoji_repl(matchobj) -> str:
3839
return re.sub(r"(\:[a-zA-Z0-9-_+]+\:)(\:skin-tone-[2-6]\:)?", emoji_repl, text)
3940

4041

42+
@cache
4143
def get_emoji_regex():
4244
"""Returns a regex to match any emoji
4345

0 commit comments

Comments
 (0)