[issue25898] Check for subsequence inside a sequence

2019-08-22 Thread Raymond Hettinger
Raymond Hettinger 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.) Yes, exactly :-) Sebastian,

[issue25898] Check for subsequence inside a sequence

2015-12-20 Thread Sebastian Linke
Sebastian Linke added the comment: Slightly modified the implementation to return the index rather than a boolean. -- Added file: http://bugs.python.org/file41374/subseq_index.patch ___ Python tracker _

[issue25898] Check for subsequence inside a sequence

2015-12-18 Thread Ethan Furman
Ethan Furman added the comment: +1 for sequences +1 for subsequence_index instead of has_subsequence +1 for returning None when not found ;) -- nosy: +ethan.furman ___ Python tracker __

[issue25898] Check for subsequence inside a sequence

2015-12-18 Thread R. David Murray
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 o

[issue25898] Check for subsequence inside a sequence

2015-12-18 Thread Sebastian Linke
Sebastian Linke added the comment: @Josh What is the point of using iterators here? If the user wants an iterator to be checked then he can throw that iterator right away because it was exhausted by the function. I think that in most cases the user wants to do some postprocessing on a hairstac

[issue25898] Check for subsequence inside a sequence

2015-12-17 Thread Josh Rosenberg
Josh Rosenberg added the comment: Aho Corasick doesn't seem likely to be useful here; it's good if the haystack is huge (or you have many haystacks to search) and you have many needles to look for (and the needles never change), but it pays a fairly steep setup cost; for a utility that searche

[issue25898] Check for subsequence inside a sequence

2015-12-17 Thread Josh Rosenberg
Josh Rosenberg added the comment: A utility like this seems like it would belong in `itertools`, not `collections`. It should also ideally avoid fully realizing the sequence so it could work with iterators/generators as well; PySequence_Fast will force creation of a `list`/`tuple` of the whole

[issue25898] Check for subsequence inside a sequence

2015-12-17 Thread Serhiy Storchaka
Changes by Serhiy Storchaka : -- assignee: -> rhettinger ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https

[issue25898] Check for subsequence inside a sequence

2015-12-17 Thread Марк Коренберг
Марк Коренберг added the comment: Really optimal search algorithm should be something like that: https://en.wikipedia.org/wiki/Aho%E2%80%93Corasick_algorithm -- nosy: +mmarkk ___ Python tracker ___

[issue25898] Check for subsequence inside a sequence

2015-12-17 Thread Emanuel Barry
Emanuel Barry added the comment: Reviewed the Python code (unlike what my email said, it doesn't LGTM; I'm tired and just forgot). I checked the C code for the obvious pitfalls (didn't spot any), but it will require someone else better than me to look at it. -- nosy: +ebarry stage: ->

[issue25898] Check for subsequence inside a sequence

2015-12-17 Thread Ethan Furman
Changes by Ethan Furman : -- nosy: +rhettinger ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.pyt

[issue25898] Check for subsequence inside a sequence

2015-12-17 Thread Sebastian Linke
New submission from Sebastian Linke: With the attached patch I propose to add a new function to the "collections" module. It is meant to be used for determining whether a given subsequence is part of a particular sequence (with respect to the ordering of the subsequence). Doing this in pure