[Python-ideas] A possible transition plan to bytes-based iteration and indexing for binary data
Steven D'Aprano
steve at pearwood.info
Sun Jun 15 17:36:01 CEST 2014
A further thought comes to mind...
On Sun, Jun 15, 2014 at 10:33:14PM +1000, Nick Coghlan wrote:
[...]
> The general principle involved would be to return an integer *subtype*
> >>> bytes(b'hello'[0])
> b'h'
Hmmm. This is, I think, worrying. Now you have two sorts of ints:
a = b'hello'[0]
b = 104
assert a == b # succeeds
assert bytes(a) == bytes(b) # fails
I can see problems where one of these _ByteInts gets used where you're
expecting a regular int, or visa versa, and you're left with a silent
failure and perplexing, hard to diagnose behaviour.
--
Steven
More information about the Python-ideas
mailing list