Migrate Iter.filter_star to the Rust iterator backend#26
Closed
Copilot wants to merge 3 commits into
Closed
Conversation
Co-authored-by: OutSquareCapital <166045166+OutSquareCapital@users.noreply.github.com>
Co-authored-by: OutSquareCapital <166045166+OutSquareCapital@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Migrate Iter::filter_star
Migrate May 30, 2026
Iter.filter_star to the Rust iterator backend
| func: Callable[[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10], bool], | ||
| ) -> Iter[tuple[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]]: ... | ||
| @overload | ||
| def filter_star[U: AnyIter](self: Iter[U], func: Callable[..., bool]) -> Iter[U]: ... |
| @override | ||
| def __next__(self) -> tuple[T, ...]: ... | ||
|
|
||
| class FilterStar[T: Iterable[Any]](Iterator[T]): |
Owner
There was a problem hiding this comment.
Does this work with the overloads at the call site?
| from pyochain import Iter, Seq | ||
|
|
||
|
|
||
| def test_filter_star_preserves_non_tuple_iterables() -> None: |
Owner
There was a problem hiding this comment.
trivial tests like this should be documented in the docstring.
| slf | ||
| } | ||
|
|
||
| fn __next__(slf: PyRefMut<'_, Self>) -> PyResult<Option<Py<PyAny>>> { |
Owner
There was a problem hiding this comment.
So at each iteration we copy each element in a Vec to unbind it?? this must be slow as fuck, as this been measured?
I didn't see any benchmark result by the way.
I'm not sure we want to support non-tuples.
We already don't for the for_each_* methods anyway.
OutSquareCapital
requested changes
May 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Iter.filter_starwas still using the Python fallback while adjacent iterator adapters had already moved to the Rust-backed_toolsmodule. This change migratesfilter_starto the same backend without changing its external behavior, including support for unpacking non-tuple iterable elements.Rust iterator adapter
_tools.FilterStarinrust/src/tools.rstuplePython API wiring
Iter.filter_star()to delegate totls.FilterStar(...)filter_starfrom the remaining Python-side Rust migration TODO listTyping surface
_tools.pyistub forFilterStarIter.filter_staroverloads with a generic iterable fallback so strict typing matches the runtime behaviorRegression coverage
filter_starwith non-tuple iterable elements to guard the preserved unpacking semantics