
On Mon, May 23, 2011 at 5:33 PM, Greg Ewing <greg.ewing@canterbury.ac.nz> wrote:
Stefan Behnel wrote:
Even CPython could optimise b'x'[0] into a constant, if people ever find this to be a bottleneck.
The need to write such circumlocutions would still be a nuisance, though.
Not a nuisance enough to warrant a syntax change, IMO. Note that one of the proposed alternatives, 0'b' visually is very similar to b'x'[0]. There are plenty of other options available to users. My own favorite is probably, if bytesdata[i] == 98: # ord('b') .. In some cases, when single-byte values have protocol mnemonics, it may be more appropriate to give them descriptive names: quit_code = ord('q') if bytesdata[i] == quit_code: .. Finally, I find it rare to have single-byte codes at fixed positions in protocols. More often such codes are found after splitting the bytes data on some kind of separator.