From ecc116e4a28301eb97b6a858ac5e571c2db96275 Mon Sep 17 00:00:00 2001 From: SukramJ Date: Tue, 20 Aug 2024 16:29:26 +0200 Subject: [PATCH] Avoid excessive memory usage in cache (#1649) --- changelog.md | 4 ++++ hahomematic/caches/persistent.py | 8 +++----- pyproject.toml | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/changelog.md b/changelog.md index bedf4394..03182bb8 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,7 @@ +# Version 2024.8.9 (2024-08-20) + +- Avoid excessive memory usage in cache + # Version 2024.8.8 (2024-08-18) - Refactor folder handling diff --git a/hahomematic/caches/persistent.py b/hahomematic/caches/persistent.py index 9ec3345f..3b479d9d 100644 --- a/hahomematic/caches/persistent.py +++ b/hahomematic/caches/persistent.py @@ -286,7 +286,7 @@ def __init__(self, central: hmcu.CentralUnit) -> None: ) # {(device_address, parameter), [channel_no]} - self._address_parameter_cache: Final[dict[tuple[str, str], list[int]]] = {} + self._address_parameter_cache: Final[dict[tuple[str, str], set[int]]] = {} @property def raw_paramset_descriptions(self) -> dict[str, dict[str, dict[str, dict[str, Any]]]]: @@ -399,10 +399,8 @@ def _init_address_parameter_list(self) -> None: device_address, parameter, ) not in self._address_parameter_cache: - self._address_parameter_cache[(device_address, parameter)] = [] - self._address_parameter_cache[(device_address, parameter)].append( - channel_no - ) + self._address_parameter_cache[(device_address, parameter)] = set() + self._address_parameter_cache[(device_address, parameter)].add(channel_no) async def load(self) -> DataOperationResult: """Load paramset descriptions from disk into paramset cache.""" diff --git a/pyproject.toml b/pyproject.toml index 69322159..2bb3282e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "hahomematic" -version = "2024.8.8" +version = "2024.8.9" license = {text = "MIT License"} description = "Homematic interface for Home Assistant running on Python 3." readme = "README.md"