-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Try a MapSet implementation #3242
Comments
@lexmag interested in experimenting with this one? |
@josevalim sure, would love to try. |
We could consider cheating and have |
@ericmj in that case we have to deal with |
Yeah, may or may not be worth it. |
Yeah, i didn't figure out a way to handle |
I've made initial implementation of |
If I read them correctly, the results are really, really good. Please do send a pull request. :) |
And before I forget, thank you for doing this! ❤️ 💚 💙 💛 💜 |
My pleasure. Will send WIP PR soonish; the results are really good, but as you might see I've done the tests not for all the functions (only BIF-based), most interesting ones are left. 😄 |
With Erlang 18 coming out, I am starting to believe that the fastest way to implement a Set would actually be by using a map behind the scenes. After all, a Set is a map where having a given key means the entry exists in the set.
So here is what I have in mind. We create a new MapSet struct, that implements the Set behaviour. MapSet will be defined as follows:
And all functions would work on top of this set but return a
%MapSet{...}
struct. Once implemented, we could benchmark and see how it fares against the current HashSet. Note Map is faster than a HashDict on all operations on Erlang 18 (here is some sample benchmarking) although we may be slower in sets due to the %MapSet{} struct indirection. We need the indirection however if we want it to work as a struct (and have protocols and what not).The text was updated successfully, but these errors were encountered: