-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Make copymutable public and add clarification to some docstrings
#51939
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
Closed
Closed
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
cfd187a
update sort docstring
50daaf5
make copymutable public
3b02a30
clarify that users should not typically need to override copymutable
fcf6313
Grammar
LilithHafner a03e2ef
xref similar
LilithHafner 6647c1d
add to manual
d12cb60
clarify docstring and add StaticArrays example
aa09871
Merge branch 'master' into lh/sort-copymutable-doc
LilithHafner 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 hidden or 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 hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1114,6 +1114,7 @@ public | |
| split_rest, | ||
| tail, | ||
| checked_length, | ||
| copymutable, | ||
|
|
||
| # Loading | ||
| DL_LOAD_PATH, | ||
|
|
||
This file contains hidden or 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 hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -137,6 +137,7 @@ Base.tail | |
| Base.step | ||
| Base.collect(::Any) | ||
| Base.collect(::Type, ::Any) | ||
| Base.copymutable(::Any) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm hesitant to make |
||
| Base.filter | ||
| Base.filter! | ||
| Base.replace(::Any, ::Pair...) | ||
|
|
||
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.
Maybe I don't have a recent-enough julia version installed, but
sort(::Dict)for me produces a vector ofPairand not a sorted dictionary, do you confirm this changed?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.
Related question, does
sort(::Dict)returning a vector works thanks to the fact thatcopymutableis not yet specialized forDict? Would implementingcopymutable(d::Dict) = copy(d)break this? Would it make sense to supportsort(Set(1)), and does it currently fail only becausecopymutableis used (instead ofcollect) forSet?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 other words, while
copymutableseems fine for arrays, I wonder whethercollectwouldn't be better thancopymutablefor other iterables. Ascopymutablefor arrays is just a thin wrapper atopsimilar, mentioning "similarfor arrays andcollectfor iterable" might be simpler than introducing anothercopymutableconcept.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.
Haha, it's piracy by OrderedCollections that allows
sort(::Dict)to work.OrderedCollectionsjust gets loaded as a transitive dependency in my startup.jl file so I didn't realize. Also the piratedsort(::Dict)method is deprecated.I don't like
sort(::Dict)returning a vector of pairs, that is rarely what the user wants and it precludes the possibility of creating a better data structure instead.