<div dir="ltr">The point is to have a Pythonic way of saying that.  Using islice or iterating over a range and indexing is ugly.  It would be cleaner to implement a string class that implements fast slicing than those unpythonic pieces of code.<div><br></div><div>Best,</div><div><br></div><div>Neil</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, May 7, 2015 at 2:26 PM, Terry Reedy <span dir="ltr"><<a href="mailto:tjreedy@udel.edu" target="_blank">tjreedy@udel.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 5/7/2015 11:46 AM, Steven D'Aprano wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Wed, May 06, 2015 at 07:05:15PM -0700, Neil Girdhar wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Since strings are constant, wouldn't it be much faster to implement string<br>
slices as a view of other strings?<br>
</blockquote>
<br>
String or list views would be *very* useful in situations like this:<br>
<br>
# Create a massive string<br>
s = "some string"*1000000<br>
for c in s[1:]:<br>
     process(c)<br>
</blockquote>
<br></span>
Easily done without slicing, as discussed on python-list multiple times.<br>
<br>
it = iter(s)<br>
next(it)<br>
for c in it: process(c)<br>
<br>
for s[5555: 399999], use explicit indexes<br>
<br>
for i in range(5555, 400000): process s[i]<br>
<br>
or use islice.<br>
<br>
The use case for sequence views is when one needs to keep around both the base sequence and the slices (views).<span class="HOEnZb"><font color="#888888"><br>
<br>
-- <br>
Terry Jan Reedy</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
_______________________________________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org" target="_blank">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" target="_blank">https://mail.python.org/mailman/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" target="_blank">http://python.org/psf/codeofconduct/</a><br>
<br>
-- <br>
<br>
--- You received this message because you are subscribed to a topic in the Google Groups "python-ideas" group.<br>
To unsubscribe from this topic, visit <a href="https://groups.google.com/d/topic/python-ideas/II-4QRDb8Is/unsubscribe" target="_blank">https://groups.google.com/d/topic/python-ideas/II-4QRDb8Is/unsubscribe</a>.<br>
To unsubscribe from this group and all its topics, send an email to <a href="mailto:python-ideas%2Bunsubscribe@googlegroups.com" target="_blank">python-ideas+unsubscribe@googlegroups.com</a>.<br>
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank">https://groups.google.com/d/optout</a>.<br>
</div></div></blockquote></div><br></div>