Add caching to the distance calculation utility (#107626)

pull/107642/head
J. Nick Koston 2024-01-08 21:51:56 -10:00 committed by GitHub
parent 49e3c740cc
commit 1e4d10efe1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 0 deletions

View File

@ -5,6 +5,7 @@ detect_location_info and elevation are mocked by default during tests.
from __future__ import annotations
import asyncio
from functools import lru_cache
import math
from typing import Any, NamedTuple
@ -57,6 +58,7 @@ async def async_detect_location_info(
return LocationInfo(**data)
@lru_cache
def distance(
lat1: float | None, lon1: float | None, lat2: float, lon2: float
) -> float | None: