Skip to content

Conversation

@jath03
Copy link
Owner

@jath03 jath03 commented Nov 6, 2025

No description provided.

@felipecrs
Copy link

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 openrgb-python.

@felipecrs
Copy link

Oh, worth noting that we may get something like this from OpenRGB itself:

https://gitlab.com/CalcProgrammer1/OpenRGB/-/issues/5178#note_2870690945

@jath03
Copy link
Owner Author

jath03 commented Nov 6, 2025

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.

@jath03
Copy link
Owner Author

jath03 commented Nov 6, 2025

One thing to note is that python's hash is not stable across processes, if that matters to you.

@jath03
Copy link
Owner Author

jath03 commented Nov 6, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants