-
Notifications
You must be signed in to change notification settings - Fork 39
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
Is push!
implemented correctly?
#118
Comments
Presumably this is only an issue with pre-existing keys. To me, it's not entirely obvious what the right answer is. Anyone else have any thoughts? For reference, Python now guarantees that their dicts are ordered and here's what they do: >>> d = {'x':1, 'y':2}
>>> d.
d.clear( d.fromkeys( d.items( d.pop( d.setdefault( d.values(
d.copy( d.get( d.keys( d.popitem( d.update(
>>> d['x'] = 3
>>> d
{'x': 3, 'y': 2} They don't have the analog of |
Exactly; I'm also not certain what's "correct" here. I was somewhat surprised to find that |
It's basically to support adding k/v pairs without needing to destructure the pair. But if your mental model of On balance I lean towards thinking the current behavior is consistent, but it would be fine to leave this open and see if anyone else chimes in. |
I agree the current behavior is consistent. Insertion order is preserved. Using If someone really needs to update the order, they'll have to first delete the key and then re-insert it. |
If someone has a concrete proposal for how to make this clearer, let's get that out explicitly. Otherwise I propose we close this issue. |
We don't provide a docstring for That could then explain this |
I just recently discovered that
push!
is implemented forDict
and it states the following in the docstring:Because of this I sort of (maybe naively) expected
push!(::OrderedDict, ::Pair)
to always insert entries at the end, but this doesn't seem to be the case:Is this intentional?
The text was updated successfully, but these errors were encountered: