8000 Make HSV NamedTuple creation more efficient by sdb9696 · Pull Request #1211 · python-kasa/python-kasa · GitHub
[go: up one dir, main page]

Skip to content

Make HSV NamedTuple cr 8000 eation more efficient #1211

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion kasa/iot/iotbulb.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,9 @@ def _hsv(self) -> HSV:
saturation = light_state["saturation"]
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
async def _set_hsv(
Expand Down
4 changes: 3 additions & 1 deletion kasa/smart/modules/color.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ def hsv(self) -> HSV:
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):
"""Raise error on invalid brightness value."""
Expand Down
Loading
0