-
-
Notifications
You must be signed in to change notification settings - Fork 399
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
[Containers] add support for Base.getindex(::Container; kwargs...) #3237
Merged
Merged
Changes from 27 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
02201a3
WIP: [Containers] add support for Base.getindex(::Container; kwargs...)
odow 13ba3cc
Updates
odow 32c7c09
Updates
odow 4fdbc4f
More tests
odow 1108b74
Update
odow aaab0d6
Fix formatting
odow 15a2f5b
Updates
odow fe501a7
Fix formatting
odow e645cfe
Update docs/src/manual/containers.md
odow 569b550
More tests and update docs
odow 1b12ad6
Fix DenseAxisArrayView getindex
odow bbd6aaa
Fix formatting
odow 743a696
Fix docs and improve coverage
odow 8c3a46c
Clarify arrays can't use kwargs
odow 47ba2e0
More docs
odow a9d5f54
Add ENABLE_KEYWORD_INDEXING
odow e92df40
Fix formatting
odow 4468531
Add enable_container_keyword_indexing
odow b3a3f9b
Fix docs
odow 6ddbe48
Apply suggestions from code review
odow e54ebd4
Apply suggestions from code review
odow 5af91f9
Improve docstring
odow 405fd7a
Update
odow da504e0
Update
odow bc7e213
Fix scope issue
odow f105fe6
Fix
odow dbfdca7
Revert to an error for getindex
odow 4a348fc
Apply suggestions from code review
odow 9f99aa5
Update error for []
odow File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
getindex
is performance sensitive. Is there any impact from this extra!isempty(kwargs)
in the case of all positional arguments?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.
Nope. It gets compiled away:
There's still room to improve the
kwarg
option, but let's settle on the syntax/opt-in stuff first: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.
Is kwarg indexing fundamentally 10x slower than positional indexing? If that's true we might want to reconsider the syntax.
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.
No, if you change the method to a singular
getindex(x; kwargs...)
it comes down to 12ns and 0 allocations, but then I needed to add a bunch of additional methods to avoid ambiguities. Left as-is for now while we sort the syntax.Keyword indexing in general does have a slight performance hit though.
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.
In fact, keyword indexing can be as fast as Cartesian indexing if the tuple of names is encoded into the customized array type, but it is obviously not an option for JuMP now.