Live data from Hacker News

New features you can't use unless you are in Python 3

asmeurer.com

161–170 of 264 posts

Re: New features you can't use unless you are in Python 3

#161

Earlier quoted context omitted.

Compare these instead: for i in range(n): yield i yield from range(n)

Both seem quite readable, really. Seems similar to the usual "list comprehensions vs. for loop" arguments; to which I always think "use whichever is readable for the given code".

The old way hit the interpreter on every loop iteration.

Re: New features you can't use unless you are in Python 3

#162
post #67

Earlier quoted context omitted.

It was source-level incompatible with older code so it couldn't be used as a smooth transition like... almost any other language upgrade I've ever seen. Breaking code like this was a big mistake in my opinion - it resulted in many people sticking on the old version for code and library compatibility. There are still libraries which don't work on Python 3, though now fairly few of them. In addition to that, the unicod…

> It was source-level incompatible with older code so it couldn't be used as a smooth transition like... almost any other language upgrade I've ever seen. Ruby released the source-incompatible Ruby 1.9 just months before Python 3. IIRC most versions of Swift have been source-incompatible with each other. Even a language as buttoned-down as C++ has made source-incompatible changes[1]. I have no idea where people got t…

Drastically changing the behavior of the most commonly used internal type (string) is a really hard breaking change. Not disputing the why, but for some code, that's a huge change. One that automated tools like 2to3 don't help with.

Re: New features you can't use unless you are in Python 3

#163
I still don't think that any of those new functions justifies the need of a total compatibility breakdown, like the one that was artificially induced from python2.7 to python3.

Python3 is good, but should have happened as a smooth transition from python2.7. The way it was handled was just a mess, and still keeps polluting the Python world.

Next time somebody asks what Java has over Python... here it is: nothing like the python 2 vs 3 mess.

Re: New features you can't use unless you are in Python 3

#164
post #148

Earlier quoted context omitted.

> This is just silly. It will take at least 100x more effort to rewrite the project in Java than it would to upgrade to Python 3. Yes, but in return it will bring a 10x performance improvement in lots of areas, and the option of a whole lot more sturdy statically checked code.

if performance is a problem, then start rewriting the critical pieces right now because python 2 also isn't for you. mypy is a much better type system than Java, btw, if that's what you're after.

Can you expand on "mypy is a much better type system than Java"? I'd love it if that were true.

Re: New features you can't use unless you are in Python 3

#165
post #10
post #4

I'm impressed how much Python seems stuck on older versions. What went wrong?

Because after nearly 10 years this mediocre list is the best they can offer as consolidation for breaking your code, and for much of that time they didn't have everything it does now. If py3k shipped with something like https://gregoryszorc.com/blog/2017/03/13/from-__past__-impor... there probably would have been more uptake.

You've had 10 years to get off your duff and prepare for a 3.x migration while maintaining backward compatibility.

Re: New features you can't use unless you are in Python 3

#166
post #82
post #9

Earlier quoted context omitted.

It wasn't broke and they fixed it. Python 2 is a mature language with a robust ecosystem. Those just don't go away no matter how much developers nag people to upgrade.

Except it was, and badly. Unicode support reached sanity matching Java or C#, if only just, but for me the most important fix was making exceptions actually work instead of being a broken pile of workarounds glued together with ambiguous and/or confusing syntax.

For some definition of "badly" that doesn't include a huge community of working software I guess. My point wasn't that Python 3 isn't better (or even "better enough") it's that no matter how much better Your Favorite Different Thing is, it will never be better enough to make people stop using their working software.

Re: New features you can't use unless you are in Python 3

#167

Ruby's 1.8 to 1.9 transition seemed to go much smoother - I'm curious what the difference is. Just down to what is essentially better source comparability I guess.

Ruby 1.8 to 1.9 was a similar mess for a shorter period of time, and not because it was handled better, but because there was less diverse entrenched code and subcommunities to deal with: when Rails and popular Rails libraries worked, most of the community could move; Python had a whole lot more that had to be addressed, the curse of it's broader success. (Also, being already expression-oriented, Ruby didn't have to…

Didn't Ruby 1.9 also offer a meaningful performance boost as well? Whereas early Py3 was actually about 5-10% slower than Py2.

Re: New features you can't use unless you are in Python 3

#168

I still don't think that any of those new functions justifies the need of a total compatibility breakdown, like the one that was artificially induced from python2.7 to python3. Python3 is good, but should have happened as a smooth transition from python2.7. The way it was handled was just a mess, and still keeps polluting the Python world. Next time somebody asks what Java has over Python... here it is: nothing like…

Honestly, if they had just keep the print statement, the push back would have been almost non-existent.

It was that one change that pushed python 3 from "some programs and libraries will need to be written" to "almost every single program and intro to python tutorial needs to change".

Re: New features you can't use unless you are in Python 3

#169
post #20

Does anyone use 2.x by choice? I've only seen it required as to not break legacy code.

I haven't figured out the proper incantations to install matplotlib on python 3.x on OSX. So I stick with 2.7.

I would recommend you to try the intel python distribution. Comes with highly optimized numpy, scipy, matplotlib, pandas and so on. Everything compiled with icc and linked with MKL (intels BLAS library).

Re: New features you can't use unless you are in Python 3

#170

Earlier quoted context omitted.

> Whether a function for which an operator is overloaded is “cute” or “fundamental to clarity” depends on the context in which it is used. The fact that it requires context other than the language spec is where the problem resides. The cognitive overhead of reading code is high enough without having to alias common operators.

> The cognitive overhead of reading code is high enough without having to alias common operators. The cognitive overhead of reading code is, IME, often lower with context-approprate operator overloading (just as it is with well-chosen vs. poorly-chosen method names.) There is a reason human languages (and, yes, even the notation of mathematics) develops context-specific dialects, and it is to reduce the cognitive ove…

Another interesting example is in PyParsing, which can overload + and | and a few other things to produce BNF-style grammar parsers inside of Python code.
Post reply on HN