-
-
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
decouple kwargs performance improvement from API changes #25290
Conversation
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.
@@ -57,6 +57,7 @@ include("reduce.jl") | |||
include("bitarray.jl") | |||
include("bitset.jl") | |||
include("abstractdict.jl") | |||
include("iterators.jl") |
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.
Maybe we should move IndexValue
to its own file?
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.
We could, but seemed useful enough to be able to call pairs (required Zip) and generator Filter and we may want to use the Product iterator for Cartesian arrays, so I’ve wanted this file before anyways.
I think this is fine, for the sake of fixing #25177. That covers the most noticeable API change, but there are still other breaking API changes --- kwargs not being a vector --- but I think those are fine and should stay. I just want to be clear that the performance and API changes are not completely de-coupled. |
I've updated https://github.com/bramtayl/Keys.jl master for 0.7 to take advantage of dot overloading and constant progogation (it also requires the master version of RecurUnroll). It provides a named tuple implementation that
|
That seems interesting. What do you mean by "allows constant propagation"? |
Hmm, wait, maybe I was confused about that. I was looking at
But this seems to work with named tuples as well:
I thought I had read somewhere that constant propagation doesn't survive named tuples? |
Here's an example of that: test() = (a = 1, b = 2.0).a + 1 |
Hmm, I see basically identical generated code to
It seems like it propagates up to
|
`(block | ||
,(scopenest | ||
keynames | ||
(map (lambda (v dflt) | ||
(let* ((k (decl-var v)) | ||
(rval0 `(call (top getfield) ,kw (quote ,k))) | ||
(rval0 `(call (top getindex) ,kw (inert ,k))) |
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.
Will constant prop work here? I thought it was only enabled for getproperty
currently.
This undoes the breaking API change introduced by #24795 (fixing #25177), while keeping the performance / inference improvement. This lets us develop the kwargs API independent of Core.NT, for example, to provide proper deprecations for future changes, specific error messages, and work towards possible future development of NT (for example, implementing it as just another normal type in Julia, rather than requiring a special cases in the runtime).