-
-
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
RFC: Split delete!(h::Dict,key) into pop!(), delete!() (#3405) #3439
Conversation
Nice, it seems like a good change and definitely pushes the conversation forward. Now it feels a little like |
I think I've finished all of the needed At this point, I have some thoughts, and could use some feedback.
Other ideas:
Edit: |
Shall we try to get this merged for 0.2? |
I feel that this generalizes the meaning of |
@StefanKarpinski, that sounds fine. I'll add the corresponding |
After staring at this a little, I'm wondering if there is need for a method to return both the modified collection and the removed element... For immutable collections, I think this would be required. Thoughts? |
Those versions wouldn't have the |
True, that! One more thought:
This generally seems like reasonable behavior for |
I think the asymmetry of |
Okay, makes sense.
Can you clarify this statement? Is it that you want At this point, the decision is somewhat arbitrary, just wondering if you had something specific in mind. |
Reading your earlier suggestion again, I'll deprecate |
Okay, I added Tests pass (on my machine, at least). The warnings are a bit annoying. The problem is that I can squash and/or turn off the warnings, although I think the change of meaning of |
This is also one of those changes where it would be nice if a package could depend on a particular non-release version of julia (cf #3465). |
Current |
Worth keeping in mind that @lindahua is currently using |
Bump. Given @JeffBezanson's recent comments, it seems like some version of this pull request will likely go into 0.2. Rebasing is slightly painful, so I'd rather not go through it too many more times. If someone can give a heads up when they want to review/try this more, I'll rebase again. |
Let's merge this. @StefanKarpinski ? |
In the morning, I'll
One other question: should |
I thought part of the purpose of |
@JeffBezanson, you're absolutely right. I had somehow forgotten that that was one of the main points of this change. |
Give me a bit to look over this. |
* Add documentation for pop!(collection, key[, default]) * Deprecate Set add! in favor of push!, for symmetry with pop! * Also: add push!(h::Dict, k, v) for symmetry with pop!(h::Dict)
I just rebased to the latest julia, and made a few minor changes. I didn't squash the last commit yet so you can see what these are. Tests pass for me (we'll see what Travis says). As I pointed out before, because this changes the behavior of |
Re:Travis, clang passed, gcc failed. Passed with gcc on my machine. cc: @staticfloat |
@@ -223,6 +222,9 @@ export PipeString | |||
@deprecate finfer code_typed | |||
@deprecate disassemble(f::Function,t::Tuple) code_llvm(f,t) | |||
@deprecate disassemble(f::Function,t::Tuple,asm::Bool) (asm ? code_native(f,t) : code_llvm(f,t)) | |||
@deprecate add(s::Set, x) push! | |||
@deprecate add!(s::Set, x) push! |
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.
These deprecations are not quite right: the rhs needs to be push!(s,x)
.
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.
Whoops, right, thanks.
Behold; the Travis gods have deemed a re-run of the |
@staticfloat, I saw the gear, but "re-run job" was grayed out. |
You must not have permissions then. :/ I'm not sure how github permissions On Thu, Aug 8, 2013 at 12:54 PM, Kevin Squire notifications@github.comwrote:
|
bump |
I'm not quite finished installing all packages (Pkg2 is still slow, and until a moment ago, I wasn't smart enough to catch errors for uninstallable package, so I kept on restarting it). A quick grep shows that the number of packages using |
The packages below all use Packages using the return value of Packages which may want to make the same change: All packages using Uses of
Before this patch (#3439) is applied, uses of x = delete!(dict, value[, default]) or want a KeyError() thrown may want to change these uses to something like the following so that their code does not break when this patch is applied:
After this patch is applied, this can simply be changed to x = pop!(dict, value[, default]) |
These should have been copied in the last note... CC: @toivoh!, @slycoder!, @zachallaun!, @carlobaldassi!, @HackerSchool!, @jverzani!, @meggart!, @jiahao!, @dcjones |
Should that be |
It should, thanks. Fixed in the issue. |
Wouldn't it be cleaner to do:
and then just use For my part, I'm happy just waiting for this patch to land and then updating PyCall within the next day or so. Until Julia 0.2 is released, backwards compatibility is not worth messy code for me. |
That would also be fine. And since you're in charge of your package, doing nothing and letting things break for a little while is fine as well. I tend to want to But I keep getting pushback on this, and I admit that 1) it's rather annoying and 2) is mostly just creating extra work for maintainers at this early stage of julia's evolution. So now that most relevant parties have been notified, I guess we should just merge this and pick up the pieces and be done with it. (After @StefanKarpinski gives his blessing.) (There also aren't as many uses as I first feared.) |
@StefanKarpinski, do you plan to review this any more? I'd like to make a general announcement on the mailing list, and pull the trigger a day or two later. |
Yes, sorry for the slowness. |
No worries, I'll wait. |
Ok, just went over this with @JeffBezanson and I think we should follow through on this. It leads, however, to further logical changes, such as replacing |
Ah, hell. I'm just merging. |
RFC: Split delete!(h::Dict,key) into pop!(), delete!() (#3405)
@StefanKarpinski, thanks for merging. I was hoping to submit a pull request for at least |
PS. Why is it |
I think |
Update delete! usage in response to JuliaLang/julia#3439
Update delete! usage in response to JuliaLang/julia#3439
As discussed in #3405, here are some exploratory changes to split
delete!(h::Dict, key)
into two functions.pop!(h::Dict, key)
returns the value removed fromh
, or throws an error if the key missingpop!(h::Dict, key, default)
returns the value removed fromh
, ordefault
if the key is missingdelete!(h::Dict, key)
discards the value and returns the modified dictionary; no error thrown on missing value.Also implemented for
Set()
,IntSet()
.Haven't touchedObjectIdDict
orWeakKeyDict
.Edit: Added info about errors, default value on
pop!()
Edit: Also updated
ObjectIdDict
,WeakKeyDict