8000 Make HSV NamedTuple creation more efficient (#1211) · python-kasa/python-kasa@673a322 · GitHub
[go: up one dir, main page]

Skip to content

Commit 673a322

Browse files
authored
Make HSV NamedTuple creation more efficient (#1211)
1 parent 6d8dc1c commit 673a322

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

kasa/iot/iotbulb.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,9 @@ def _hsv(self) -> HSV:
367367
saturation = light_state["saturation"]
368368
value = self._brightness
369369

370-
return HSV(hue, saturation, value)
370+
# Simple HSV(hue, saturation, value) is less efficent than below
371+
# due to the cpython implementation.
372+
return tuple.__new__(HSV, (hue, saturation, value))
371373

372374
@requires_update
373375
async def _set_hsv(

kasa/smart/modules/color.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ def hsv(self) -> HSV:
4444
self.data.get("brightness", 0),
4545
)
4646

47-
return HSV(hue=h, saturation=s, value=v)
47+
# Simple HSV(h, s, v) is less efficent than below
48+
# due to the cpython implementation.
49+
return tuple.__new__(HSV, (h, s, v))
4850

4951
def _raise_for_invalid_brightness(self, value):
5052
"""Raise error on invalid brightness value."""

0 commit comments

Comments
 (0)
0