On 5/7/2015 11:46 AM, Steven D'Aprano wrote:
On Wed, May 06, 2015 at 07:05:15PM -0700, Neil Girdhar wrote:
Since strings are constant, wouldn't it be much faster to implement string
slices as a view of other strings?
String or list views would be *very* useful in situations like this:
# Create a massive string
s = "some string"*1000000
for c in s[1:]:
Easily done without slicing, as discussed on python-list multiple times.
it = iter(s)
for c in it: process(c)
for s[5555: 399999], use explicit indexes
for i in range(5555, 400000): process s[i]
or use islice.
The use case for sequence views is when one needs to keep around both the base sequence and the slices (views).
Terry Jan Reedy
Python-ideas mailing list
Code of Conduct: http://python.org/psf/codeofconduct/
--- You received this message because you are subscribed to a topic in the Google Groups "python-ideas" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/python-ideas/II-4QRDb8Is/unsubscribe.
To unsubscribe from this group and all its topics, send an email to firstname.lastname@example.org.
For more options, visit https://groups.google.com/d/optout.