Conversation
|
Hm... thank you! But I think this is not more optimized than what I am currently doing. However, you made me realize that I could simplify the implementation by hashing the entire data attribute. Something like: def _compute_state_hash(self) -> int:
"""Compute a hash of device states."""
state_data = ""
for device in self.coordinator.client.devices:
state_data += str(device.data)
return hash(state_data)Also, it's completely fine if you disagree this being a good idea to be added to |
|
Oh, worth noting that we may get something like this from OpenRGB itself: https://gitlab.com/CalcProgrammer1/OpenRGB/-/issues/5178#note_2870690945 |
|
Maybe eventually, but sounds like the recommendation is to do this ourselves for now. I wouldn't mind having this in the library. I wasn't really expecting to get any performance differences, and updating devices is already a relatively slow operation, so I doubt this would make any significant impact. The main benefit to having this in the library is that it gets updated/computed only when devices updates are received from openrgb. So you're not computing hashes all the time whenever you want to check the state. |
|
One thing to note is that python's hash is not stable across processes, if that matters to you. |
|
Eh, I'm reconsidering the decision to hash on every update. Adding extra cycles when most people will not need it is unnecessary. Sounds like you have a solution that will work for you, so I'm closing this. |
No description provided.