Skip to content

Send a phone call from AI agent, in an API call. Or, directly call the bot from the configured phone number!

Python

perf: Limit cache for phone number, ease RAM

Clémence Lesnéa54f031459b8
diff --git a/helpers/pydantic_types/phone_numbers.py b/helpers/pydantic_types/phone_numbers.py
index fb2508c..5d7cb3b 100644
--- a/helpers/pydantic_types/phone_numbers.py
+++ b/helpers/pydantic_types/phone_numbers.py
@@ -1,5 +1,5 @@
from datetime import tzinfo
-from functools import cache
+from functools import lru_cache
from pydantic_extra_types.phone_numbers import PhoneNumber as PydanticPhoneNumber
from pytz import country_timezones, timezone, utc
import phonenumbers
@@ -8,7 +8,7 @@ import phonenumbers
class PhoneNumber(PydanticPhoneNumber):
phone_format = "E164" # E164 is standard accross all Microsoft services
- @cache # TODO: Is it necessary to cache this?
+ @lru_cache # Cache results in memory as func is executed many times on the same content
def tz(self: PydanticPhoneNumber) -> tzinfo:
"""
Return timezone of a phone number.