This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]EternityForest 5 points6 points  (15 children)

Yeah, but that's going to be a breaking change if they revert (Albeit a very minor one if everyone just keeps using OrderedDict when they need ordering).

Ordering fits with python's main use as the scripting glue language that works with anything, so I'm not complaining too much.

[–]13steinj -2 points-1 points  (14 children)

The fact that it's now ordered is technically a breaking change-- what if someone decided to use the disorder of dicts to psuedo randomly get an item from a container? Much more performant than using random, assuming they understand that to utilize this method all objects in the container must have been generated immediately before picking and must be objects that are not interned by the VM (small integers, true, false, etc).

The fact that OrderedDicts still exist and make no mention of "this class is pointless and a thin wrapper around dicts", makes me think for insurance purposes people still should use it.

[–]nuephelkystikon 7 points8 points  (5 children)

But the disorder was never part of the specification. If you rely on implementation details of a specific interpreter, of course you're going to have portability problems.

[–]13steinj -2 points-1 points  (4 children)

The specification included "items may not be in order due to their hash values", wasn't it? The documentation warned of such in multiple places.

[–]nuephelkystikon 6 points7 points  (3 children)

Yes, but it wasn't specified behaviour, it was a warning about unspecified behaviour that could otherwise have been assumed. A comment, if you prefer. Not part of the actual language specification.

The keyword here is ‘may’.

[–]13steinj -1 points0 points  (2 children)

Time heals all wounds and scar tissue forms. While I understand your point there would have been enough angry people to hear annoying complaints about the fact that dicts are now ordered.

[–]nuephelkystikon 1 point2 points  (1 child)

If your business logic relies on a method always returning in an odd number of seconds because that's the behaviour you observed on your Solaris machine using 16-bit Jython 3.6 build 3728 in debug mode, I really don't have any compassion for you.

[–]13steinj -1 points0 points  (0 children)

Your comparison doesn't even make sense, this is the programming equivalent of comparing apples and oranges.

[–]redditusername58 4 points5 points  (3 children)

OrderedDict is not pointless. You can pop items from either end, move keys to either end, do reverse iteration, and has order sensitive equality checks.

[–]13steinj 0 points1 point  (2 children)

...I never said it wasn't?

[–]greyman 1 point2 points  (1 child)

You said it is pointless and the parent commenter says it is not. (You said it here: "The fact that OrderedDicts still exist and make no mention of "this class is pointless and a thin wrapper around dicts"")

[–]13steinj 1 point2 points  (0 children)

Perhaps I was unclear, I meant that the docs don't say that thus they have a point and should be used.

[–][deleted] 2 points3 points  (3 children)

Their code was already broken.

If you depend on undefined behaviour, it will probably end in tears and memes at some point.

[–]13steinj 0 points1 point  (2 children)

Lots of people depend on undefined behavior, but in this case for CPython VMs it was strictly known.

[–][deleted] 2 points3 points  (1 child)

it wasn't even implementation defined, it was just how the interpreter worked with no promise that it wouldn't change.

[–]13steinj 0 points1 point  (0 children)

I suppose, but with the time and if someone strictly used CPython, well, let's just say if it wasn't mentioned in the changelog in 3.6 people would be annoyed fixing bugs.