-
-
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
use named tuples as keyword varargs. fixes #4916 #24795
Conversation
NEWS.md
Outdated
* Keyword argument containers (`kw` in `f(; kw...)`) are now named tuples. Dictionary | ||
functions like `haskey` and indexing can be used on them, and name-value pairs can be | ||
iterated using `pairs(kw)` ([#4916]). | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if it'd be worth mentioning that keyword arguments can no longer be repeated; I know that wasn't changed explicitly in this PR, but seems like a good place to mention it anyway.
235ea5a
to
b4415e8
Compare
What constant propagation would that be? Currently that PR can’t really do anything for NamedTuples (which would likely need more of a MemSSA or GVN pass). |
The code here calls |
b4415e8
to
b8d7882
Compare
b8d7882
to
3764b9d
Compare
also fixes #9972
d201bf0
to
afbc8f2
Compare
Fix keyword handling related to the changes in JuliaLang#24795
fix deprecation of IOContext after #24795
What's the timing now that #24362 merged? |
It's not measuring anything... julia> f(;kw...) = g(;kw...)
f (generic function with 1 method)
julia> g(;kw...) = kw
g (generic function with 1 method)
julia> const c = g(a=1, b=2)
(a = 1, b = 2)
julia> @time for i in 1:1000; f(a=1, b=2); end
0.000003 seconds
julia> @time for i in 1:1000; f(;c...); end
0.000003 seconds |
This starts to decouple the performance improvement of #24795 from the existence of exactly one implementation of Core.NamedTuple, in preparation for implementing NamedTuple in Julia rather than C.
This starts to decouple the performance improvement of #24795 from the existence of exactly one implementation of Core.NamedTuple, in preparation for implementing NamedTuple in Julia rather than C.
Same highly-biased benchmark as #21915 (~100x speedup):
This also helps a lot towards #9551. The PR makes the lowering of keyword argument methods simpler and easier to optimize (note the net code deletion). In fact I think just a bit of constant propagation (#24362) on top of this will solve the problem entirely.
Also fixes #9972.