R. David Murray added the comment:

If I were trying to channel Raymond I'd suggest posting the python as a recipe 
and see if there is uptake.  However, I could be wrong and he might be 
interested.  (I can't say that I've ever needed this check myself.)

I'd be inclined to agree that it should only work on sequences and be in 
collections.  If you can come up with a real use case where you wouldn't need 
the realized haystack afterwards I'd be interested to hear it :)  Regardless, I 
don't see how it could be composed with other itertools, so it doesn't seem to 
belong there.

As long as one is finding the needle, one might as well return the index, 
though.  So subsequence_index instead of has_subsequence.  And then you'd want 
an optional start index, and maybe an rsubsequence_index :)  So, it could be a 
method of Sequence, but is it useful enough to be worth adding?  Do any other 
languages have such a function as part of their built in toolkit?

(Aside: you can avoid creating a subsequence by using a loop.  You'd have to 
test with a bunch of variant sizes to see which is more efficient, but I'm 
guessing it would be the loop.)

----------
nosy: +r.david.murray

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue25898>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to