Skip to content
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

Check two IntelHex objects equality #57

Open
diggit opened this issue Mar 30, 2022 · 7 comments
Open

Check two IntelHex objects equality #57

diggit opened this issue Mar 30, 2022 · 7 comments

Comments

@diggit
Copy link

diggit commented Mar 30, 2022

Hi,
I am looking for effective way of hex file data comparison, mainly equality check.
Is there already some effective way of comparison?

Did you consider overriding of __eq__ ?

@diggit
Copy link
Author

diggit commented Mar 30, 2022

Using equality check over output of segments() seems to work.
My second question remains.

@bialix
Copy link
Member

bialix commented Mar 30, 2022

Due to internal data storage model there is no effective way for byte to byte comparison, that's actually O(n) operation.

@diggit
Copy link
Author

diggit commented Mar 31, 2022

By "effective way", I meant something what does not have to repack data and do other unnecessary operations. Preferably in __eq__. O(n) is fine and probably expected.

@bialix
Copy link
Member

bialix commented Mar 31, 2022

Unfortunately, internally it has to repack data for comparing.

@diggit
Copy link
Author

diggit commented Mar 31, 2022

I peeked into sources and IntelHex._buf seems like dict of address->data.
Equality comparison then would be just comparison of those dicts when taking account few other option (offset,...).
Am I wrong?

@bialix
Copy link
Member

bialix commented Mar 31, 2022

Yes, that's correct.

@bialix
Copy link
Member

bialix commented Mar 31, 2022

Sorry, it seems I haven't thought enough about your question. So basically all you need is to compare this._buf to other._buf.
Yep, that should be easy addition. Patches welcome, and please provide some tests.

Also, there is hexdiff.py script to compare two Intel Hex files, you might look into using it. Actually, no, sorry.

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

No branches or pull requests

2 participants