mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 21:57:51 +00:00
Add caching to the distance calculation utility (#107626)
This commit is contained in:
parent
49e3c740cc
commit
1e4d10efe1
@ -5,6 +5,7 @@ detect_location_info and elevation are mocked by default during tests.
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
|
from functools import lru_cache
|
||||||
import math
|
import math
|
||||||
from typing import Any, NamedTuple
|
from typing import Any, NamedTuple
|
||||||
|
|
||||||
@ -57,6 +58,7 @@ async def async_detect_location_info(
|
|||||||
return LocationInfo(**data)
|
return LocationInfo(**data)
|
||||||
|
|
||||||
|
|
||||||
|
@lru_cache
|
||||||
def distance(
|
def distance(
|
||||||
lat1: float | None, lon1: float | None, lat2: float, lon2: float
|
lat1: float | None, lon1: float | None, lat2: float, lon2: float
|
||||||
) -> float | None:
|
) -> float | None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user