This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author cameron
Recipients Ramchandra Apte, abarnert, cameron, christian.heimes, cowlicks, georg.brandl, gregory.p.smith, gvanrossum, josh.r, martin.panter, pitrou, rhettinger, serhiy.storchaka, socketpair, terry.reedy, vstinner
Date 2016-05-14.23:49:39
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1463269779.89.0.948949353072.issue19251@psf.upfronthosting.co.za>
In-reply-to
Content
I'd like speak my support for bitwise ops on bytes and bytearray (agree, on equal lengths only).

I've got 2 arguments here:

- readability: a ^ b, a | b and so forth are clear and direct

- all the various incantation presented must be _understood_, not to mention invented anew by anyone wanting to do they same, with the same burden of getting it correct; of course one can say the same of any feature not already present in a language but that is trite; there are several ways to say this and all have varying degrees of speed, obtuseness and verbosity. And they're all SLOW.

Regarding some of the counter arguments in the discussion:

- gregory.p.smith in reply to cowlicks: "Security claims?  Nonsense. This has nothing to do with security.  It is *fundamentally impossible* to write constant time side channel attack resistant algorithms [...]"

Maybe cowlicks should have said "reliable", though to my naive eye a normal implementation would be constant time for a given size. I would argue that the clarity and directness of just writing "a^b" immediately makes for trivially correct code, which itself is a necessary prerequisite for secure code.

- gregory.p.smith again: "Neither of the above "look as nice" as a simple operator would. But they are at least both understandable and frankly about the same as what you would naively write in C for the task."

This is not an argument against the feature. That one had to perform similar activitie in Python as in C merely reflects the present lack of these operators, not a preexisting gleaming sufficiency of operator richness.

- Terry J. Reddy: "'XOR of two bytes in one place' strikes me as a thin excuse for a new feature that abbreviates a simple, short, one-liner". Christian Heimes's code has this single example, but anyone wanting to work on chunks of bytes may find themselves here. Just because a lot of things can be written/constructed as one liners doesn't mean they should be operators when (a) the operator is available (==unused) for this type, (b) the meaning of the operator is straight forward and intuitive and (c) any pure Python construction is both wordier and much slower.

Anyway, I an for this feature, for the record.
History
Date User Action Args
2016-05-14 23:49:40cameronsetrecipients: + cameron, gvanrossum, georg.brandl, rhettinger, terry.reedy, gregory.p.smith, pitrou, vstinner, christian.heimes, socketpair, Ramchandra Apte, martin.panter, serhiy.storchaka, abarnert, josh.r, cowlicks
2016-05-14 23:49:39cameronsetmessageid: <1463269779.89.0.948949353072.issue19251@psf.upfronthosting.co.za>
2016-05-14 23:49:39cameronlinkissue19251 messages
2016-05-14 23:49:39cameroncreate