Re: c-types Structure and equality with bytes/bytearray

2021-04-29 Thread Eryk Sun
On 4/26/21, Michael Hull wrote: > > my understanding was that `bytes` and `bytearray` would normally > be expected to work quite interchangeably with each other? bytearray.__eq__() is more flexible: >>> i = Int16(first=65, second=66) >>> bytearray(i).__eq__(i) True >>> i.__eq__(

c-types Structure and equality with bytes/bytearray

2021-04-26 Thread Michael Hull
Hello everyone, I've been working with ctypes recently, and I've come across what seems to be some slightly confusing behaviour, when comparing ctype's Structure against `bytes` and `bytearray` objects import ctypes class Int(ctypes.Structure): _fields_ = [("first_16", ctypes.c_int8),