From 0cb36aa74f8181453db9cf438d3115e92e9df650 Mon Sep 17 00:00:00 2001 From: Robyn Speer Date: Fri, 9 Mar 2018 14:54:03 -0500 Subject: [PATCH] cache the language info (avoids 10x slowdown) --- wordfreq/language_info.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/wordfreq/language_info.py b/wordfreq/language_info.py index 73b88f6..feb5ef1 100644 --- a/wordfreq/language_info.py +++ b/wordfreq/language_info.py @@ -1,3 +1,4 @@ +from functools import lru_cache from langcodes import Language, best_match @@ -34,6 +35,7 @@ def _language_in_list(language, targets, min_score=80): return matched[1] > 0 +@lru_cache(maxsize=None) def get_language_info(language): """ Looks up the things we need to know about how to handle text in a given