-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document and export Base.in!
#51636
Document and export Base.in!
#51636
Conversation
Great find - The name feels incomplete for what it does, but given operations on containers generally return the container, having something different makes sense. Unless there should (also?) be a method should return a tuple of the set and whether the value was already present or not. No strong opinions here, just some thoughts. I'd like having the operation available. |
Comes from #45156 with some initial discussion. |
Let's hope it makes it into 1.11 ! Co-authored-by: Petr Vana <petvana@centrum.cz>
I think `in!` is a useful general function for users, and would be good to have as official API. Its semantics is clear and unambiguous, while providing a clear performance advantage over the naive implementation. For more evidence that this functionality is useful, consider: * Rust's `HashSet::insert` works just like this implementation of `in!` * This function was already used in the implementation of `Base.unique`, precisely for the performance over the naive approach Comes from JuliaLang#45156 with some initial discussion.
I think
in!
is a useful general function for users, and would be good to have as official API. Its semantics is clear and unambiguous, while providing a clear performance advantage over the naive implementation.For more evidence that this functionality is useful, consider:
HashSet::insert
works just like this implementation ofin!
Base.unique
, precisely for the performance over the naive approachThis PR currently doesn't have any tests - I will add them if the API addition of PR is approved.