[Python-Dev] Python 3.x and bytes (original) (raw)
"Martin v. Löwis" martin at v.loewis.de
Wed May 18 22:06:26 CEST 2011
- Previous message: [Python-Dev] Python 3.x and bytes
- Next message: [Python-Dev] Python 3.x and bytes
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Here's another thought, that perhaps is not backwards-incompatible...
somevar[3] == b'd' At some point, the bytes class' eq will be called -- is there a reason why we cannot have 1) a check to see if the bytes instance is length 1 2) a check to see if i) the other object is an int, and 2) 0 <= otherobj < 256 3) if 1 and 2, make the comparison instead of returning NotImplemented?
Immutable objects that compare equal should hash equal; so we would also have to change the hashing of byte strings. Not sure whether that, in turn, has undesirable consequences.
In addition, equality should be transitive, so b'A' == 65.0.
Regards, Martin
- Previous message: [Python-Dev] Python 3.x and bytes
- Next message: [Python-Dev] Python 3.x and bytes
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]