-
-
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
Proposal: Dict constructors from tuples #4871
Comments
Of course, the easiest way to implement the second constructor would be Dict{K,V}(kv::Array{(K,V)}) = Dict{K,V}(zip(kv...)...) |
I'm curious why you closed this? I do think that the collection constructors could use some review for consistency and completeness – Dicts, Sets, Arrays (which are already quite good). |
Sorry, should have explained better. After making the comment above, I simply created a pull request for the new Since it uses the other constructors, there didn't seem much point in asking to remove them, and the constructor itself is trivial. |
Dict literals work by calling the |
How about changing the |
(Reopening because of this discussion...) |
That would be ok, but the current implementation was picked for efficiency. Of course I could use a hidden |
I guess my main motivation in wanting to simplify the Dict{A,B}(::Type{A},::Type{B}) can exist. Right now, it conflicts with the The above construction would be useful because:
|
I wonder how much slower would this be: Dict(ks, vs) = Dict{eltype(ks), eltype(vs)}(ks,vs) This would subsume the current interfaces, and still allow Dict{A,B}(::Type{A},::Type{B}) to exist. |
Just putting out feelers: I'd like to propose:
removing constructing
Dicts
fromtuples
as is currently done(from https://github.com/JuliaLang/julia/blob/master/base/dict.jl#L302)
add a dict constructor from a list of tuple pairs (as the inverse of
collect
on a Dict)Item 1 seems like a vestige from before we had literal dict construction--is this used anywhere?
Item 2 seems like an oversight.
The text was updated successfully, but these errors were encountered: