[Python-ideas] Bitwise operations on bytes class

Nick Coghlan ncoghlan at gmail.com
Tue Jun 17 08:02:36 CEST 2014


On 17 Jun 2014 10:04, "Chris Angelico" <rosuav at gmail.com> wrote:
>
> On Tue, Jun 17, 2014 at 10:00 AM, Greg Ewing
> <greg.ewing at canterbury.ac.nz> wrote:
> > Chris Angelico wrote:
> >>
> >> 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.
> >
> >
> > Why not both?
>
> If you do a series of operations on a large bytes object, each one
> will involve a full copy. If you do the same series of operations on a
> large mutable object, they can be optimized down to non-copying. Why
> both?

Because the two APIs are currently in sync outside mutating operations, and
there isn't a compelling reason to break that symmetry, even if this
proposal was put forward as a PEP and ultimately accepted.

Cheers,
Nick.

>
> ChrisA
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140617/341362dd/attachment-0001.html>


More information about the Python-ideas mailing list