[Python-ideas] Why don't CPython strings implement slicing using a view?

Serhiy Storchaka storchaka at gmail.com
Thu May 7 14:07:49 CEST 2015


On 07.05.15 05:05, Neil Girdhar wrote:
> Since strings are constant, wouldn't it be much faster to implement
> string slices as a view of other strings?
>
> For clarity, I'm talking about CPython.  I'm not talking about anything
> the user sees.  The string views would still look like regular str
> instances to the user.

Note that String in Java was implemented as a view of underlying array 
of chars. This allowed sharing character data and fast (constant time) 
slicing. But the implementation was changed in Java 7u6.

http://java-performance.info/changes-to-string-java-1-7-0_06/



More information about the Python-ideas mailing list