[Python-ideas] Bitwise operations on bytes class

Steven D'Aprano steve at pearwood.info
Tue Jun 17 02:55:33 CEST 2014


On Tue, Jun 17, 2014 at 08:59:30AM +1000, Chris Angelico wrote:
> On Tue, Jun 17, 2014 at 6:16 AM, Nathaniel McCallum
> <npmccallum at redhat.com> wrote:
> > Of course my attached code is slow. This is precisely why I'm proposing
> > native additions to the bytes class.
> 
> I presume you're aware that the bytes type is immutable, right? You're
> still going to have at least some copying going on, whereas with a
> mutable type you might well be able to avoid that. Efficiency suggests
> bytearray instead.

The very first sentence of Nathaniel's first post in this thread:

"I find myself, fairly often, needing to perform bitwise operations
(rshift, lshift, and, or, xor) on arrays of bytes in python (both bytes
and bytearray)."

So yes, I think he is aware of it :-)



-- 
Steven


More information about the Python-ideas mailing list