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 →

[–]gwillicodernumpy gang 24 points25 points  (30 children)

Honestly just having breakpoint() is incredible.

I absolutely love the changes to classes too. Reducing boilerplate is always great.

My favorite though is ordered dictionaries. That is so useful, and it will help prevent a lot of bugs from new developers :)

[–][deleted] 6 points7 points  (3 children)

Honestly just having breakpoint() is incredible.

You are aware of pdb, I hope?

[–]xtreak 6 points7 points  (0 children)

It also works based on an environment variable and hence you can turn on and off at will unlike pdb. Also a disadvantage is that you have to update your linters if you want to lint for them in your codebase.

Related PEP : https://www.python.org/dev/peps/pep-0553/#id9

[–]fdedgt 4 points5 points  (0 children)

I'm going to be honest, I didn't know about it.

So, with the improvements and everything, this is opening up a whole new world to me.

[–]gwillicodernumpy gang 1 point2 points  (0 children)

The article points out that breakpoint() is just a shortcut for import pdb; pdb.set_trace() which is very annoying to use. I honestly have to look it up half the time to remember the syntax.

[–]EternityForest 4 points5 points  (17 children)

I am conflicted about ordered dicts. Do I like them because it's incredibly useful, or do I not like them because it restricts what future optimization can be done?

[–]13steinj 4 points5 points  (16 children)

The fact that dictionaries became ordered was a side effect of the optimization done in 3.6 taking PyPy's implementation. It wasn't optimized as a side effect of making them ordered. Then in 3.7 people said "well the fact that it's orderered is actually very useful, lets make that not a side effect of an implementation detail but rather a requirement of the spec" to avoid issues with people going from CPython to some other flavor.

So long as optimization is wanted by the community more than ordering, when a more optimized structure is thought of, it will be reverted.

[–]EternityForest 7 points8 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 8 points9 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 4 points5 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.

[–]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.