[Python-ideas] proposed sequence method: index_subseq()
Tal Einat
taleinat at gmail.com
Wed Aug 28 10:57:52 CEST 2013
On Wed, Aug 28, 2013 at 11:43 AM, Steven D'Aprano <steve at pearwood.info> wrote:
> On Wed, Aug 28, 2013 at 11:21:36AM +0300, Tal Einat wrote:
>> You meant that the searched sequence would be an iterator, not the
>> sub-sequence, right? This should be possible with KMP or similar
>> algorithms (e.g. as described under the "Variants" section in the KMP
>> Wikipedia article).
>
> What would be the point of that? Having searched the iterator for some
> sub-sequence, you will have consumed the iterator and can no longer do
> anything with the values consumed.
One use case, just off the top of my head, would be to search a bunch
of files, some potentially very large, for some text or data.
Requiring the loading of each file into memory just for a search is
unnecessary.
> I think it is perfectly reasonable to insist on actual sequences for
> sub-sequence testing, even if the algorithm happens to work on
> iterators.
As far as I can tell, restricting this to searching in sequences would
gain nothing, but would make this unfit for searching very large data
sets.
- Tal
More information about the Python-ideas
mailing list