mirror of
https://github.com/python-kasa/python-kasa.git
synced 2024-12-22 19:23:34 +00:00
Make HSV NamedTuple creation more efficient (#1211)
This commit is contained in:
parent
6d8dc1cc5f
commit
673a32258f
@ -367,7 +367,9 @@ class IotBulb(IotDevice):
|
|||||||
saturation = light_state["saturation"]
|
saturation = light_state["saturation"]
|
||||||
value = self._brightness
|
value = self._brightness
|
||||||
|
|
||||||
return HSV(hue, saturation, value)
|
# Simple HSV(hue, saturation, value) is less efficent than below
|
||||||
|
# due to the cpython implementation.
|
||||||
|
return tuple.__new__(HSV, (hue, saturation, value))
|
||||||
|
|
||||||
@requires_update
|
@requires_update
|
||||||
async def _set_hsv(
|
async def _set_hsv(
|
||||||
|
@ -44,7 +44,9 @@ class Color(SmartModule):
|
|||||||
self.data.get("brightness", 0),
|
self.data.get("brightness", 0),
|
||||||
)
|
)
|
||||||
|
|
||||||
return HSV(hue=h, saturation=s, value=v)
|
# Simple HSV(h, s, v) is less efficent than below
|
||||||
|
# due to the cpython implementation.
|
||||||
|
return tuple.__new__(HSV, (h, s, v))
|
||||||
|
|
||||||
def _raise_for_invalid_brightness(self, value):
|
def _raise_for_invalid_brightness(self, value):
|
||||||
"""Raise error on invalid brightness value."""
|
"""Raise error on invalid brightness value."""
|
||||||
|
Loading…
Reference in New Issue
Block a user