Skip to content

add FilterRejectUnstable implementations - #904

Open
hizani wants to merge 1 commit into
samber:masterfrom
hizani:filter-reject-unstable
Open

add FilterRejectUnstable implementations#904
hizani wants to merge 1 commit into
samber:masterfrom
hizani:filter-reject-unstable

Conversation

@hizani

@hizani hizani commented Jun 10, 2026

Copy link
Copy Markdown

This PR adds a new FilterRejectUnstable function to both the mutable and lo packages. Benchmarks show that the mutable implementation is 7–10x faster than the original lo.FilterReject on my machine.

I understand that introducing an unstable version is a controversial choice, but I couldn’t come up with a similarly efficient stable implementation (at least not as clean as this one). The performance gain justifies this approach for me.


I first implemented only an in‑place version in the mutable package but then I realized that this approach could also be useful in the lo package. Although its speed is not much faster than the original FilterReject, it cuts memory usage in half compared to the original implementation, which makes it especially helpful for large collections.

@hizani hizani mentioned this pull request Jun 10, 2026
@hizani

hizani commented Jun 10, 2026

Copy link
Copy Markdown
Author

In defense of this solution I can say that in my tasks it often doesn’t matter in what order the function returns the results. I believe there are as many cases where order doesn't matter as there are cases that require stable implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant