[Python-Dev] Optimization
Georg Brandl
g.brandl at gmx.net
Sun Oct 6 08:38:12 CEST 2013
Am 06.10.2013 01:37, schrieb Antoine Pitrou:
> On Sun, 6 Oct 2013 09:32:30 +1000
> Nick Coghlan <ncoghlan at gmail.com> wrote:
>> On 6 Oct 2013 08:59, "Antoine Pitrou" <solipsis at pitrou.net> wrote:
>> >
>> > On Sat, 5 Oct 2013 15:35:30 -0700
>> > Raymond Hettinger <raymond.hettinger at gmail.com> wrote:
>> > >
>> > > Making bytearray's efficiently pop from the left side is dubious.
>> > > This isn't a common idiom, nor should it be. Even if all the
>> > > other implementations could model this behavior, it wouldn't
>> > > be a good idea to have bytearrays have different performance
>> > > characteristics than strings.
>> >
>> > Bytearrays are mutable and strings are immutable, so evidently they
>> > will have different performance characteristics.
>>
>> I suspect "list" may have been the intended comparison there. "array.array"
>> is another appropriate comparison.
>>
>> Having bytearray operations differ in algorithmic complexity from those two
>> types would be very strange and surprising (particularly if it was CPython
>> specific).
>
> It's only strange because you don't understand the main use case for
> bytearrays. They may look like arrays of 8-bit integers but they are
> really used for buffers, so optimizing for stuff like FIFO operation
> makes sense.
I agree, that is also what came to my mind when I read the commit message.
Georg
More information about the Python-Dev
mailing list