This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author r.david.murray
Recipients abarry, josh.r, r.david.murray, rhettinger, seblin, socketpair
Date 2015-12-18.16:15:48
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
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.)
Date User Action Args
2015-12-18 16:15:48r.david.murraysetrecipients: + r.david.murray, rhettinger, socketpair, josh.r, abarry, seblin
2015-12-18 16:15:48r.david.murraysetmessageid: <>
2015-12-18 16:15:48r.david.murraylinkissue25898 messages
2015-12-18 16:15:48r.david.murraycreate