Nick Coghlan writes: > 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
I don't see why. If you really wanted bytearrays to be similar to list or array.array in that way, wouldn't you derive them from one of those types[1] rather than provide a primitive? Having a separate primitive makes it easier to implement optimized performance characteristics. Isn't that why we have several different kinds of containers instead of deriving everything from list? For me, the point about string "+=" being efficient (sometimes) isn't that it is surprising compared to similar types, it's that it is surprising for any immutable sequence type. Footnotes: [1] Or all of them from an ABC. _______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com