Check two IntelHex objects equality
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__ ?
~~Using equality check over output of segments() seems to work.~~
My second question remains.
Due to internal data storage model there is no effective way for byte to byte comparison, that's actually O(n) operation.
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.
Unfortunately, internally it has to repack data for comparing.
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?
Yes, that's correct.
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.