<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>On May 14, 2015, at 08:44, Alexander Atkins <<a href="mailto:alexander@tutorfair.com">alexander@tutorfair.com</a>> wrote:</div><div><br></div><blockquote type="cite"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div id=":1w0" class="a3s" style="overflow:hidden">A slice is just a subsequence of indexed values. If you can index it,<br>
you should be able to slice it.<br>
<br>
assert spam[start:end:step] == [spam[i] for i in range(start, end, step)]</div></blockquote></div><br>What I was trying to do was to create a slice without losing the laziness.  For example, in my implementation you can take a slice like foo[start:] from an infinite sequence without causing problems.  I haven't quite done it right, because I've returned an iterator instead of another LazyList object, but I could fix it up.  I discuss this a bit more in the example program given in the repository.</blockquote><br><div>Having gone through this whole idea before (and then never finding a good use for it...), that's the only hard part--and the easiest way to solve that hard part is to create a generic sequence view library, which turns out to be more useful than the lazy list library anyway.</div><div><br></div><div>(Plus, once you build the slice view type of the sequence view abstract type, it's pretty easy to build a deque- or rope-like sequence of discontiguous, or even different-source, slices, at which point tail-sharing becomes trivial, which makes lazy lists a lot more useful.)</div><div><br></div><div>One more thing: a lot of the problems you (at least if you're thinking the same way I was) think you want lazy lists for, you only need tee--or you only need tee with its cache exposed so you can explicitly access it. Being able to directly index or slice or even delete from it as a sequence is a neat problem to solve, but it's hard to find a case where explicitly working on the cache is significantly less readable, and it's a lot simpler.</div><div><br></div><div>But anyway, if you think it could be useful to someone else, you don't need to ask python-ideas whether to upload it to PyPI; just do it.</div></body></html>