News for hackers. Stuff that matters.
Re:Why Is the Migration to Python 3 Taking So Long? by downerending on Thursday November 14, 2019 @12:38PM (#21537436)
Because there's been not enough carrot and too much stick.

The only real killer feature of Python3 is the async programming model. Unfortunately, the standard library version is numbingly complex. (Curio is far easier to follow, but doesn't appear to have a future.)

On the down side, switching to Unicode strings is a major hurdle. It mostly "just works", but when it doesn't, it can be difficult to see what's going on. Probably most programmers don't really understand all of the ins and outs. And on top of that, you get weird bugs like this one, which apparently is simply never going to be fixed.

https://github.com/pallets/click/issues/1212

Re:Why Is the Migration to Python 3 Taking So Long? by hermod on Thursday November 14, 2019 @01:02PM (#21537706)
With respect to async, I'm partial to trio [0], which is a spiritual successor to curio [1].

The model is similar to Golang in many ways, e.g. communication using channels [2] and cancellation [3] reminiscent of context.WithTimeout, except that in Golang you need to reify the context passing.

The author has written some insightful commentary on designing async runtimes [4] and is actively developing the library, so I'm optimistic about its future. There were plans to use it for requests v3 until the fundraiser fiasco [5].

[0] https://github.com/python-trio/trio

[1] https://vorpus.org/blog/announcing-trio/

[2] https://trio.readthedocs.io/en/stable/reference-core.html#us...

[3] https://trio.readthedocs.io/en/latest/reference-core.html#ca...

[4] https://vorpus.org/blog/notes-on-structured-concurrency-or-g...

[5] https://vorpus.org/blog/why-im-not-collaborating-with-kennet...

Re:Why Is the Migration to Python 3 Taking So Long? by privateSFacct on Thursday November 14, 2019 @01:36PM (#21538008)
I was curious about [5]

The link to support requests (which is a great piece of software) is here:

https://cash.app/$KennethReitz

Note: This is NOT a charitable donation, it is a gift to an individual. These are not tax deductible under US law.

Njs has a long attacking blog post saying this needs to go through PSF (huh?) and that they should be getting most of this money not the person the funds were directed towards (it's not clear how much they've actually contributed to requests over time). This supposedly also may trigger folks who have also suffered from "gaslighting".

Supporting the developer of a piece of software does not, as far as I know, require that they sign up to handle it on a charitable basis. A big todo is made about the "large" amount raised. The amounts is 33K. To be frank, this is almost zero in tech land at least in the bay area and requests is a very highly used project. I was literally expecting something like 300K or even $1M - silly kickstarter projects raise for more and deliver nothing. Requests has already delivered a lot of utility.

Just a bit of perspective from someone who wasn't familiar with this "fiasco".

Re:Why Is the Migration to Python 3 Taking So Long? by shkkmo on Thursday November 14, 2019 @03:47PM (#21539226)
I don't have a horse in the game and I'm not familiar with these people or the "fiasco" but your summary does not seem like accurate description of the issues raised in [5]. Here are the quotes that give me a very different take on the situation:

The money was raised specifically to support development of requests 3

> [Reitz] announced that work had begun on "Requests 3", that its headline feature would be the native async/await support I was working on, and that he was seeking donations to make this happen.

It's not so much that PSF needed to be used, as that there needed to be some accountability as to how those funds were used.

> [Reitz] chose a fundraiser structure that avoids standard accountability mechanisms he was familiar with. He never had any plan or capability to deliver what he promised. And when I offered a way for him to do it anyway, he gave me some bafflegab about how expensive it is to write docs. Effectively, his public promises about how he would use the Requests 3 money were lies from start to finish, and he hasn't shown any remorse or even understanding that this is a problem.

It sounds like a great deal of the work being done on requests is done by volunteers but the funding only goes to support Reitz

> I think a lot of people don't realize how little Reitz actually has to do with Requests development. For many years now, actual maintenance has been done almost exclusively by other volunteers. If you look at the maintainers list on PyPI, you'll see he doesn't have PyPI rights to his own project, because he kept breaking stuff, so the real maintainers insisted on revoking his access. If you clone the Requests git repo, you can run git log requests/ to see a list of every time someone changed the library's source code, either directly or by merging someone else's pull request. The last time Reitz did either was in May 2017, when he made some whitespace cleanups.

The issue is not so much that money is being made, but the way that it is done and the lack of accountability

> I don't have any objection to trying to make money from open-source. I've written before about how open-source doesn't get nearly enough investment. I do object to exploiting volunteers, driving out community members, and lying to funders and the broader community. Reitz has a consistent history of doing all these things.

Re:Why Is the Migration to Python 3 Taking So Long? by privateSFacct on Thursday November 14, 2019 @11:02PM (#21542105)
The people who can and should complain if they feel misled about how their money was used are the people who donated the money. Have any of them complained? I say this with some seriousness.

NO WHERE that I can see did Reitz say he would hire NJS to do some work. Is Reitz even setup properly to report for taxes or withold taxes on amounts paid to NJS, check paperwork for work eligiblity etc? Would this even be allowable if requests is not a business, or would deductions be disallowed as non business (ie, a payment to NJS -> subject to tax to both Reitz and NJS potentially?).

If you as a donor want full charitable compliance using PSF you would ask to give through them - and perhaps more would have been given if PSF had been an option.

I don't even see NJS on the requests contributor list:

https://github.com/psf/requests/blob/master/AUTHORS.rst

Finally, requests 3 has a number of features.

Re:Why Is the Migration to Python 3 Taking So Long? by shkkmo on Friday November 15, 2019 @05:41AM (#21543829)
My take on it is that NJS was no so much upset/concerned about not getting paid as he was about the way he was treated and how this behavior affects the community.

> And on a more personal level, I felt his interactions with me were extremely manipulative. I felt like he tried to exploit me, and that he tried to make me complicit in covering up his lies to protect his reputation. I was extremely uncomfortable with the idea of going along with this, but he created a situation where my only other options were to either give up on working on async entirely, or else to go public with the whole story, at potentially serious cost to myself.

> Ultimately, I decided to speak out because I care deeply about the Python community and its members. If one of our community's most prominent members freely lies to donors and harms volunteers, and if we all let that go without saying anything, then that puts everything we've built together at risk. And I'm in a better position than many to speak up.

The intent seems not to be trying to get people to blacklist or dogpile on Reitz, but to simply make people aware of the issues so they won't get caught off guard.

> This is the classic "missing stair" problem. Those in the inner circle quietly work around the toxic person. Outsiders come in blind. I'm pretty well-connected in the Python world, and I came in blind.

> Since this is the internet, I have to say explicitly: Please do not harass or abuse Reitz. That's never appropriate

Re:Why Is the Migration to Python 3 Taking So Long? by fastball on Thursday November 14, 2019 @11:58PM (#21542296)
How can the people who donated money complain without NJS posting as he did?
Re:Why Is the Migration to Python 3 Taking So Long? by pmiller2 on Thursday November 14, 2019 @03:16PM (#21538957)
I wouldn’t say 33k is “almost zero.” For me, a single person living in the Bay Area, $33k would pay all of my expenses for a little over 6 months. When we’re talking about this amount of money going to a single individual, I don’t think it’s fair to call it “almost zero.”
Re:Why Is the Migration to Python 3 Taking So Long? by bonzini on Thursday November 14, 2019 @03:56PM (#21539304)
I suppose you would have to pay taxes on the 33k you get from a crowdfunding platform.
Re:Why Is the Migration to Python 3 Taking So Long? by privateSFacct on Thursday November 14, 2019 @05:32PM (#21540232)
You would - yes, it's considered income and you may get a 1099-K even if no 1099-MISC in many cases. The 1099-K's have caught a fair number of folks not reporting income they otherwise were getting.
Re:Why Is the Migration to Python 3 Taking So Long? by sbierwagen on Thursday November 14, 2019 @01:58PM (#21538237)
It's always amazing how adding a little money to the mix makes people lose their minds. NJS was working for free. KR raised some money from large businesses, then told NJS to keep working for free. NJS retroactively discovered that working for free is stupid, and tried demanding all the money NJS raised. This didn't happen, of course, since he had no leverage at all on NJS besides complaining online.

The takeaway here appears to be "never work for free". If NJS has worked on his own project, controlled by him alone, this wouldn't have happened. If you donate a bunch of work to an open source project, then... well... the source is open.

Re:Why Is the Migration to Python 3 Taking So Long? by privateSFacct on Thursday November 14, 2019 @11:21PM (#21542183)
Where did KR say he was going to hire NJS or give him any money? NJS is not even on the contributor list for requests I don't think - so of all the people to hire is he even at the top of queue?

And is it impossible that KR is doing an order of magnitude more work on the requests projects, with a much longer track records and raised the money directly to himself (and so has to pay taxes potentially on it) such that using it to support his work on requests is unreasonable?

Re:Why Is the Migration to Python 3 Taking So Long? by semiotagonal on Thursday November 14, 2019 @12:46PM (#21537533)
I wonder how many people feel that migrating to Python3 would have been worth doing in the absence of being forced to do so.

Dropbox invested three years of work, actually hired Python's creator, and are still not done. What are they getting out of it that they wouldn't have gotten if Python2 simply had been maintained?

Re:Why Is the Migration to Python 3 Taking So Long? by crustacean on Thursday November 14, 2019 @01:22PM (#21537876)
This is such a good point. Take SQL. It has survived because it is well designed, and changes so little and so slowly, and it’s obvious what SQL is and isn’t meant for. Amateur programmers can port SQL queries between database systems semi-painlessly. In the right environment a query can survive with small edits for YEARS.

Who wants to break old SQL? Nobody.

Re:Why Is the Migration to Python 3 Taking So Long? by skybrian on Thursday November 14, 2019 @01:42PM (#21538080)
That's something of an illusion. The flaws in SQL often aren't noticed because you usually pick one database vendor and stick with them. There are plenty of differences between vendors, but you don't usually have to support them at the same time, and you don't notice for simple cases.

But changing database vendors for a company can be a big deal, as bad as going from Python 2 to 3.

Re:Why Is the Migration to Python 3 Taking So Long? by just_myles on Thursday November 14, 2019 @05:09PM (#21540004)
This is true. But, I think he means syntactically you can make jumps from one dbms to another without much of a fuss. Obviously there are non-language features but, that is not what is being discussed here.
Re:Why Is the Migration to Python 3 Taking So Long? by setr on Thursday November 14, 2019 @06:00PM (#21540450)
That's mostly a result of databases (kinda) converging, SQL being a declarative language and it primarily being a wrapper around relational algebra, with a bunch of flags. And of course, it's a very direct interface to the RDBMS, and you're just migrating between systems that try very hard to have the same interface.

As a language however, it's a whole lot of nonsense. Extremely inconsistent syntax, stuffing a trinary logic into a boolean system, a standard that gets extended arbitrarily, and even the tooling ecosystem is a fair bit pathetic (the lack of formatters particularly annoy me; everyone tries to support SQLs generally, and end up missing every extended feature.. if it's not a simple select query/ddl, you're not getting a decent format output)

And it most certainly is a whole lot of fuss to migrate unless your database is tiny, or you didn't actually utilize the DB except as a dumb datastore (eg you relied solely on your ORM + indexes); there's a reason no good translator exists, and those that exist only support a very limited subset of any particular SQL variant, despite programming languages having a whole array of transpilers; it's simply not at all a simple language, and the variants only superficially look the same.

Re:Why Is the Migration to Python 3 Taking So Long? by just_myles on Tuesday November 19, 2019 @02:57PM (#21577526)
"As a language however, it's a whole lot of nonsense. Extremely inconsistent syntax, stuffing a trinary logic into a boolean system, a standard that gets extended arbitrarily, and even the tooling ecosystem is a fair bit pathetic (the lack of formatters particularly annoy me; everyone tries to support SQLs generally, and end up missing every extended feature.. if it's not a simple select query/ddl, you're not getting a decent format output)"

Would love to see your point in action. For me personally, speaking strictly writing simple scripts, they pretty much translate fairly well. Regarding formatting, are you referring to the output?

Re:Why Is the Migration to Python 3 Taking So Long? by wvenable on Thursday November 14, 2019 @05:49PM (#21540371)
Dealing with Unicode in SQL has long been a backwards-compatibility nightmare.
Re:Why Is the Migration to Python 3 Taking So Long? by just_myles on Monday November 18, 2019 @04:53PM (#21568506)
In all fairness, dealing with unicode in general has been a pain point for me.
Re:Why Is the Migration to Python 3 Taking So Long? by marcus_holmes on Thursday November 14, 2019 @04:58PM (#21539925)
> Who wants to break old SQL? Nobody.

Every couple of months there's a new startup / dev site that says "SQL is broken/old/bad, so we reinvented it!". They all sink without trace, but there's a cohort who agrees with them.

Re:Why Is the Migration to Python 3 Taking So Long? by setr on Thursday November 14, 2019 @06:03PM (#21540472)
The problem I think is they typically try to go ahead and reinvent the entire RDBMS as well.

It's not clear to me why postgres hasn't simply grown a whole array of frontends..

Re:Why Is the Migration to Python 3 Taking So Long? by marcus_holmes on Friday November 15, 2019 @04:35AM (#21543554)
Agree totally. I had to climb the painful learning curve of psql because none of the front ends worked the way I wanted for some reason or another. Of course, having learned psql, I'm now scathing of anyone wanting a front end... hmm... maybe that's why ;)
Re:Why Is the Migration to Python 3 Taking So Long? by setr on Friday November 15, 2019 @08:36AM (#21544612)
I was actually thinking about the lack of SQL alternatives using the postgres engine; for example, why is datalog not simply available as an extension? Or MySQL syntax? PG implements a wide array of alternatives to PL/pgSQL (including standard programming languages eg python), but for whatever reason these SQL-alts never seem to consider being layered on top of the postgres engine.

However, the lack of GUI frontends is also really weird. I don't see why it'd be harder to support than any other DB, and afaik pg has gotten fairly popular..

Re:Why Is the Migration to Python 3 Taking So Long? by marcus_holmes on Friday November 15, 2019 @10:31AM (#21545610)
true, why isn't there a MongoDb alternative that just wraps jsonb on Postgres?
Re:Why Is the Migration to Python 3 Taking So Long? by ogre_codes on Thursday November 14, 2019 @02:11PM (#21538354)
This is backwards thinking.

Yes, it's expensive to upgrade from Python 2 to Python 3, but it's also expensive for the Python project to maintain 2 versions of Python indefinitely. If someone wanted other than the core Python team wants to step up and maintain Python 2, they are free to do so, it's open source. But failing that, expecting the Python team to support the older/ less functional version of the code indefinitely is unrealistic. Corporate owned languages have even shorter lifecycles for exactly this reason.

Re:Why Is the Migration to Python 3 Taking So Long? by coldtea on Thursday November 14, 2019 @02:37PM (#21538584)
>This is backwards thinking.

And the alternative is cargo cult "newer is better".

>Yes, it's expensive to upgrade from Python 2 to Python 3, but it's also expensive for the Python project to maintain 2 versions of Python indefinitely.

On the other hand, they could progressively enhance upon a backwards compatible single 2 version. JS manages to do that just fine, as does Java...

Re:Why Is the Migration to Python 3 Taking So Long? by btreecat on Thursday November 14, 2019 @04:04PM (#21539400)
>JS manages to do that just fine

How do you define just fine? It's taken us many years to migrate EMCA versions only to have multiple incompatible runtimes.

And JS "The good parts" is like 1/10 of the full language so often it feels like a lot of pile on.

>as does Java

How are them generics?

Re:Why Is the Migration to Python 3 Taking So Long? by JaRail on Thursday November 14, 2019 @05:25PM (#21540169)
> How do you define just fine? It's taken us many years to migrate EMCA versions only to have multiple incompatible runtimes.

ECMAScript versions are forward-compatible. Any valid ECMAScript 3 code is also valid 5.1, 2015, 2016, etc.

I'm not sure what migration you're talking about. If you mean using new language features before your runtime targets support them, that's kinda on you. Even so, the ecosystem has tons of robust solutions for supporting legacy interpreters. Most notably, Babel does a wonderful job of transpiling to lower language-version targets.

Re:Why Is the Migration to Python 3 Taking So Long? by coldtea on Thursday November 14, 2019 @06:21PM (#21540623)
>How do you define just fine?

Besides the total domination of the web programming space, which is of course aided by it being the only option:

1) Used by choice even on the server and application development (where it was never the only option, and wasn't even preferable/viable before)

2) Fast pace of language development

3) A thriving package ecosystem with millions of packages

4) Adopted by all major companies

5) Three best of class runtimes (v8, JavascriptCore, Tracemonkey (?)) by 3 major vendors, with performance that smokes any dynamic language that is not LuaJit

6) Increasingly adopted as an embedded scripting language in all kind of apps

7) With a viable gateway into both a native trans-language runtime (webassembly) and a typed version of the language (typescript).

>How are them generics?

They're doing great. It's not that type erasure is that big of a deal, and Java might even get it with Valhalla eventually anyway. It's not a "backwards compatibility prevents this" issue (which is our topic here), it's a "no time devoted to add it in yet" issue.

Re:Why Is the Migration to Python 3 Taking So Long? by ageofwant on Thursday November 14, 2019 @06:59PM (#21540942)
And yet Python is eating the world: http://pypl.github.io/PYPL.html

Not that I'm implying that 'popularity' is a good measure of anything.

Re:Why Is the Migration to Python 3 Taking So Long? by ogre_codes on Thursday November 14, 2019 @07:50PM (#21541245)
Javascript is the king of compromises. It's supported by every browser on the planet so of course support is massive. It's not as if a front end web developer can choose to work on the web and not use Javascript in some form or another.

Python is popular largely based on the fact that it's so approachable. It is the BASIC/ VB of modern times for whatever that is worth. It does scale up to larger projects and is frequently used for big scale stuff, but I suspect the fact that it's so ubiquitous has more to do with the fact that it's also easy to pick up and for companies to find people with Python dev skills (or train them up).

Re:Why Is the Migration to Python 3 Taking So Long? by Volt on Thursday November 14, 2019 @09:19PM (#21541690)
Then what are you implying?
Re:Why Is the Migration to Python 3 Taking So Long? by ageofwant on Friday November 15, 2019 @10:07AM (#21545370)
Perhaps that listing all the excellent reasons for why some tech is 'better' than another does not translate into said tech being used.
Re:Why Is the Migration to Python 3 Taking So Long? by avisser on Thursday November 14, 2019 @05:18PM (#21540094)
Now do C#.

You are moving the goalposts and ignoring the fact that Python3 still didn't deliver anything for most users.

Re:Why Is the Migration to Python 3 Taking So Long? by ogre_codes on Thursday November 14, 2019 @05:24PM (#21540153)
This is a hugely American point of view. For anyone who has to deal with unicode on a regular basis, the better unicode support alone is a huge improvement. That's without even looking at the advantages of Async support which offers big performance benefits for web developers—roughly 70% of Python users.
Re:Why Is the Migration to Python 3 Taking So Long? by avisser on Thursday November 14, 2019 @05:39PM (#21540285)
Fair criticism. But shouldn't you be even more pissed that the Unicode release was botched and we're still talking about it more than 10 years after?

When I upgrade to a new version of C# ... nothing happens.

Backwards compatibility is what made Microsoft the company it is. I think Python deserves all the crap it gets for 2 vs 3.

Re:Why Is the Migration to Python 3 Taking So Long? by gggmaster on Thursday November 14, 2019 @10:13PM (#21541924)
They have to be backwards-compatible to persuade people to pay for their proprietary products rather than switch to another vendor.
Re:Why Is the Migration to Python 3 Taking So Long? by avisser on Friday November 15, 2019 @08:13AM (#21544455)
So you're saying backwards-compatibility is awesome. I agree.
Re:Why Is the Migration to Python 3 Taking So Long? by downerending on Thursday November 14, 2019 @06:09PM (#21540525)
Note that the question is not "Shall we support Unicode?". Clearly we should.

The question is rather whether it would have been better to gradually improve support for it in a Python2-esque way, rather than creating a discontinuity and a raft of new problems, some of which linger to this day.

Also, for many purposes, there is wide agreement that ASCII is still the way to go. Even if Americans vanished tomorrow, the majority of remaining programmers in the world would prefer to look at source code in English, which they already know, rather than a host of other languages, most of which they don't.

Re:Why Is the Migration to Python 3 Taking So Long? by int_19h on Friday November 15, 2019 @03:08AM (#21543149)
There was no way to gradually improve Unicode support in Python without breaking things, because a big part of it was stuff like implicit str/unicode conversions - that were broken because they practically never use the right encoding, but that you can't remove without introducing as much breakage as Python 3 did.
Re:Why Is the Migration to Python 3 Taking So Long? by spronkey on Saturday November 16, 2019 @05:15AM (#21551928)
You lack imagination here :) There are several solutions that could have been pursued, including introducing a completely new type and effectively duplicating the existing string library for it.
Re:Why Is the Migration to Python 3 Taking So Long? by int_19h on Monday November 18, 2019 @02:01PM (#21567076)
It's not just the string library that is affected. It's literally every API in the stdlib that returns a string. You'd have to fork all of those, because changing any of them to return a completely new type would be a breaking change as well.
Re:Why Is the Migration to Python 3 Taking So Long? by Myrmornis on Friday November 15, 2019 @01:07AM (#21542631)
Unicode support isn't about supporting unicode in files of source code!
Re:Why Is the Migration to Python 3 Taking So Long? by takeda on Friday November 15, 2019 @01:13AM (#21542657)
They did try to do it in Python 2 and intruded Unicode type. The problem was that not only it didn't help, it is the main reason why migration to Python 3 is so painful.
Re:Why Is the Migration to Python 3 Taking So Long? by ogre_codes on Thursday November 14, 2019 @06:33PM (#21540719)
You are replying out of context here. The comment I was replying to was specifically "Python3 still didn't deliver anything for most users". Which is just not true.
Re:Why Is the Migration to Python 3 Taking So Long? by ogre_codes on Thursday November 14, 2019 @05:51PM (#21540386)
Replying here because the other is nested too deep.

You do realize that C# was itself Microsoft's replacement for C++ right? And that when C# was released it had it's own growing pains and long roll-out in spite of having the worlds biggest corporation pushing it.

Python as a language is far older than C# so it had a lot more baggage than C# does.

Re:Why Is the Migration to Python 3 Taking So Long? by ogre_codes on Thursday November 14, 2019 @05:21PM (#21540128)
> And the alternative is cargo cult "newer is better".

Of course it's a "cargo cult" when someone disagrees with you.

> On the other hand, they could progressively enhance upon a backwards compatible single 2 version. JS manages to do that just fine, as does Java...

"Just fine"... that explains why so many shops are dropping support for straight Javascript and switching to TypeScript or CoffeeScript before that. And why Javascript is littered with band-aid libraries like Underscore that are needed to turn it into an effective development language.

Likewise, Java development is slowly being superseded by Kotlin. Java is a mess, there are often 3-4 ways to do simple things and many of them are just terrible for performance.

Re:Why Is the Migration to Python 3 Taking So Long? by coldtea on Thursday November 14, 2019 @06:27PM (#21540675)
>Of course it's a "cargo cult" when someone disagrees with you.

No, it's obviously "backwards thinking", right?

>* "Just fine"... that explains why so many shops are dropping support for straight Javascript and switching to TypeScript or CoffeeScript before that.*

CoffeeScript was just adopted (and not that much in the first place) because it brought new syntax/features earlier. Now JS has been getting new syntax itself at a great pace and CoffeeScript just died off.

As for TypeScript, this is just Javascript + type annotations. Kinda like what Python is getting with 3.6 and mypy, but more useful and with actual tooling available. So not sure how "TypeScript or CoffeeScript" prove anything about JS not doing great.

>Likewise, Java development is slowly being superseded by Kotlin. Java is a mess, there are often 3-4 ways to do simple things and many of them are just terrible for performance.

Python has 10x+ worse performance, and more than 3-4 ways to do simple things (from package management to basic libs), most of which are just terrible for performance.

Compared to that, nobody has had any problem with Java performance for 15+ years...

And Kotlin is still insignificant except in the Android space where it's pushed, so there's that. Java sees an order of magnitude more usage.

Re:Why Is the Migration to Python 3 Taking So Long? by jnxx on Thursday November 14, 2019 @04:27PM (#21539612)
> On the other hand, they could progressively enhance upon a backwards compatible single 2 version. JS manages to do that just fine, as does Java...

Common Lisp has a backwards compatibility which goes into decades, and implementations like SBCL had no difficulties at all to absorb Unicode.

Racket even supports different language standards and completely different languages (such as Scheme and Algol) running on the same runtime. And both SBCL and Racket are compiled languages with a high-end GC which should make such things more difficult than CPython, which is purely interpreted and has a simpler GC.

But the incompatibility between Python 2 and Python 3 is perhap s only a symptom of a larger problem. The Python developers have decided that backwards compatibility is not that important any more. This is not a problem for companies like Dropbox, or small start-ups, from which 95 % will not even exist in five years on. It is, however, a huge problem for domains like scientific computing, where most code has no maintainers and even for very important code there is no budget or staff for maintenance:

https://blog.khinsen.net/posts/2017/11/16/a-plea-for-stabili...

Re:Why Is the Migration to Python 3 Taking So Long? by acqq on Thursday November 14, 2019 @04:51PM (#21539862)
> But the incompatibility between Python 2 and Python 3 is perhap s only a symptom of a larger problem. The Python developers have decided that backwards compatibility is not that important any more.

Exactly: and that was a wrong decision for anybody but the developers of Python.

Everybody else prefers having something that works: "The improvements are welcome, but please allow us to to run our old programs too, thank you, and allow us to use that new feature only once we need it."

It's an obvious expectation. We would also hate a new version of a word processor which wouldn't open our old documents. Or a new version of Photoshop which wouldn't open our old pictures. Or a new version of the browser where only the newest web pages are visible.

It follows that it was absolutely technically possible to have a new version of Python in which the old programs still work. It's the failure of the developers that they haven't made it.

Compare that decision of theirs with the policy of Linus Torvalds who insists that the old user programs should never break on newer kernels.

Re:Why Is the Migration to Python 3 Taking So Long? by acqq on Friday November 15, 2019 @02:51AM (#21543080)
As an example for Linus' "kernel changes should not break user programs" policy, he was famous for using harsh words to pass the message to those who tired to steer otherwise (these words I don't have to repeat, so I'll just quote his main message):

https://lkml.org/lkml/2012/12/23/75

"How long have you been a maintainer? And you still haven't learnt the first rule of kernel maintenance?

If a change results in user programs breaking, it's a bug in the kernel. We never EVER blame the user programs."

Re:Why Is the Migration to Python 3 Taking So Long? by jnxx on Friday November 15, 2019 @04:27AM (#21543516)
To explain that a bit, a Linux kernel maintainer is somebody who organizes and collects contributions of others, screens them, and when they are finished, passes them on to Linus to integrate them. That's a huge responsibility, and Linus uses such strong expressions only for people who have such responsibility and which do things which would harm his project. It is not the case that he talks like that to normal contributors (which should be guided by the maintainers).
Re:Why Is the Migration to Python 3 Taking So Long? by jnxx on Friday November 15, 2019 @04:15AM (#21543459)
And the reason why I think there is a deeper problem is that the issue is clearly not solved with the python2/python3 transition:

Why do some python developers have to maintain installations of a whole handful of python versions just to ensure that their code is working? Why all the mess with pyenv, virtualenv, and so on? If the python developers, as well as the library developers would support backwards compatibility, this would not be necessary at all.

Re:Why Is the Migration to Python 3 Taking So Long? by acqq on Friday November 15, 2019 @05:26AM (#21543772)
> the issue is clearly not solved with the python2/python3 transition

Exactly. The incompatibility mess continues when using different 3.x versions.

Re:Why Is the Migration to Python 3 Taking So Long? by jnxx on Friday November 15, 2019 @04:32AM (#21543538)
Obligatory Reference to Rich Hickeys talk on versioning and interface specs:

https://www.youtube.com/watch?v=oyLBGkS5ICk

Discussion:

https://news.ycombinator.com/item?id=13085952

Re:Why Is the Migration to Python 3 Taking So Long? by flukus on Friday November 15, 2019 @01:15AM (#21542668)
> It is, however, a huge problem for domains like scientific computing, where most code has no maintainers and even for very important code there is no budget or staff for maintenance

I think that's a tool selection problem, not just confined to the python world. If the language and libraries won't have a supported lifespan that matches with the maintenance budget of the projects using them then the wrong tool was chosen. If a project is expected to have a 10+ year lifespan of little to no maintenance then it needs to be built on languages/libraries that will have supported versions for that long.

Re:Why Is the Migration to Python 3 Taking So Long? by jnxx on Friday November 15, 2019 @04:22AM (#21543492)
Well, first thing is that most new code in scientific research is developed in PhD projects which last some three or maybe four years. The people who develop this do not have resources and time to maintain this code. Projects don't have a budget for that. There are projects which are very long-running (think CERN or ESO's VLT) but even there the true duration of the code usage is seldomly planned (AFAIK, ESO VLT has just started to transition from Tk/Tcl to Python).

You could say then, "well, then Python is perhaps just not a good match for those pesky scientists".

And this brings up two more points:

* A lot of important tools and libraries in the Python ecosystem was developed by scientists. Numarray/Numpy is a good example.

* If the core Python developers don't have the intention to maintain a backwards-compatible language version for more than, say, 15 years, they should perhaps clearly state on the python.org main page something like: "great, as you are a scientist, we welcome your contribution, but Python might not be suitable for tools that support long-term research".

Re:Why Is the Migration to Python 3 Taking So Long? by cmacleod4 on Friday November 15, 2019 @06:09AM (#21543941)
"ESO VLT has just started to transition from Tk/Tcl to Python" - they might regret this, new Tcl releases tend to take backward compatibility much more seriously than Python :-)
Re:Why Is the Migration to Python 3 Taking So Long? by blacksqr on Friday November 15, 2019 @10:19AM (#21545490)
Yes, I've always thought that Tcl should be promoted as an archival quality programming language.
Re:Why Is the Migration to Python 3 Taking So Long? by takeda on Friday November 15, 2019 @01:36AM (#21542771)
> It is, however, a huge problem for domains like scientific computing, where most code has no maintainers and even for very important code there is no budget or staff for maintenance:

Data science is doing just fine, in fact is leading the migration: https://www.jetbrains.com/research/python-developers-survey-...

Re:Why Is the Migration to Python 3 Taking So Long? by jnxx on Friday November 15, 2019 @04:11AM (#21543437)
"data science" and "science" are quite different things. Science is the systematic and collaborative pursuit of knowledge in a long-term endeavour. It is based on sharing and open exchange of methods and tools. Numericas, mathematics and computational codes are just important tools to do that. As Hinsen in the blog post I cited above points out, the most part of important computational codes is written in one-off research projects which go for a few years, and the people who develop these codes normally have to move on and work for a different institution, if they manage to keep working in science. On the other hand, important codes and algorithms may be used for many many years.

"Data science" is a broad term but usually just means the application of numeric, and sometimes scientific, tools to commercial means. It is almost always done in companies. Typically, between such companies there is no open exchange of tools and methods, no exchange of knowledge, and no long-term use of generated codes. This is the reason why data science companies don't have the problems which Hinsen pointed out. But, they could become affected by a degrading suitability of Python for computational science, because their tools were initially developed by scientists.

Re:Why Is the Migration to Python 3 Taking So Long? by jnxx on Friday November 15, 2019 @04:34AM (#21543552)
Discussion of Hinsen's post on HN:

https://news.ycombinator.com/item?id=17058269

Re:Why Is the Migration to Python 3 Taking So Long? by sullyj3 on Thursday November 14, 2019 @03:48PM (#21539232)
Both Java and Javascript are giant messes.
Re:Why Is the Migration to Python 3 Taking So Long? by jusssi on Thursday November 14, 2019 @04:38PM (#21539729)
And yet, somehow, Python manages to be a bigger mess than than both of them combined.
Re:Why Is the Migration to Python 3 Taking So Long? by coldtea on Thursday November 14, 2019 @03:50PM (#21539252)
Java is nothing like a mess, and JS is going from strength to strength.
Re:Why Is the Migration to Python 3 Taking So Long? by voldacar on Friday November 15, 2019 @02:39AM (#21543033)

  int max = new Max(10, 5).intValue();
Re:Why Is the Migration to Python 3 Taking So Long? by coldtea on Saturday November 16, 2019 @12:06PM (#21553629)
Not sure what's that supposed to be. What's this "Max" class?

In any case, that's not some counter-argument, even if it points to a real wart.

It's "let me throw a random Java wart, as if it means something, and as if other languages don't have their own warts".

Re:Why Is the Migration to Python 3 Taking So Long? by ageofwant on Thursday November 14, 2019 @06:45PM (#21540825)
No, 'cargo culting' is when you don't understand the causal link between cause and effect. Of course "newer is better" in this case, and we know exactly why: Thousands of man days have been spend improving underlying libraries, lessons have been learnt, new ideas stolen from other languages, optimization, security improvements and so on.
Re:Why Is the Migration to Python 3 Taking So Long? by kick on Thursday November 14, 2019 @04:16PM (#21539515)
Almost everyone hates both Java and Javascript.
Re:Why Is the Migration to Python 3 Taking So Long? by ncallaway on Thursday November 14, 2019 @04:35PM (#21539692)
> Almost everyone hates both Java and Javascript.

I just don't think that's true.

Re:Why Is the Migration to Python 3 Taking So Long? by avisser on Thursday November 14, 2019 @05:19PM (#21540112)
And I dislike Python, but that's at best a cool story, bro.

This is a story about language upgrades. Those languages showed how to do it right.

Re:Why Is the Migration to Python 3 Taking So Long? by coldtea on Thursday November 14, 2019 @06:30PM (#21540698)
Javascript is a hugely popular language, as is Java.

Some hipsters hate "Java and Javascript". The world at large loves them.

At some point plain users hated Java applets and Java desktop apps, but those are not a thing much more. In the server space, very few that use it hate Java, and millions use it.

Re:Why Is the Migration to Python 3 Taking So Long? by pmoriarty on Thursday November 14, 2019 @06:42PM (#21540801)
Just because they're popular doesn't necessarily mean their users like them.

Lots of people learn and use these languages because:

1 - That's what they're taught at school.

2 - That's where many if not most programming jobs are.

3 - There are a bazillion libraries they can use, compared to other languages.

4 - JS is built in to browsers.

5 - They don't know any better.

6 - Marketing.

Also, many companies want their staff to develop in these languages because of the reasons on this list plus that's what most programmers know, so it's relatively easy to find employees.

Re:Why Is the Migration to Python 3 Taking So Long? by cerved on Friday November 15, 2019 @02:13AM (#21542931)
Ah yes, let's turn this into a good old "your language sucks" thread
Re:Why Is the Migration to Python 3 Taking So Long? by bobbylarrybobby on Thursday November 14, 2019 @03:53PM (#21539269)
JS and Java can do that because they were designed reasonably well from the start. All they tend to add are more features on top of the solid core language. Python's language was not solid (e.g., strings not unicode by default) so they needed a major overhaul.
Re:Why Is the Migration to Python 3 Taking So Long? by teh_klev on Thursday November 14, 2019 @04:45PM (#21539804)
> JS and Java can do that because they were designed reasonably well from the start.

Javascript was knocked up over a week or so. Sure it implements concepts from Scheme and other languages but it was certainly not "designed reasonably well from the start". Otherwise we wouldn't have needed books such as Crockford's "Javascript The Good Parts" to help us understand areas of the language to avoid/misuse.

> Python's language was not solid (e.g., strings not unicode by default)

From the article:

"Python itself predates the first volume of the Unicode standard which came out in October 1991."

Re:Why Is the Migration to Python 3 Taking So Long? by downerending on Thursday November 14, 2019 @04:15PM (#21539509)
Kind of an odd slam, given that Python (and most other widely used languages) predated Unicode.

In any case, I think the jury is still out on whether Unicode in the primary string type is a good idea.

Re:Why Is the Migration to Python 3 Taking So Long? by colejohnson66 on Friday November 15, 2019 @08:21AM (#21544515)
Didn’t C# come out after Unicode (1990s vs 2000)? And they still didn’t implement it properly. Instead, they went with the horrible UCS-2 because it made interfacing with the Windows API easier (it uses wchar_t (16-bit) and UCS-2).
Re:Why Is the Migration to Python 3 Taking So Long? by int_19h on Friday November 15, 2019 @03:11AM (#21543161)
It's funny that you should bring up Unicode strings as an example. Java strings aren't Unicode by modern standards - their char is fixed as 16 bits, because back in the day, UCS2 was "good enough for everybody". So the moment you have, say, an emoji, stuff like length() and indexing is no longer dealing in actual codepoints. And you can slice in the middle of a surrogate pair, and end up with an instance of String that's not even valid UTF-16.

Python didn't get Unicode until later, so it had a chance to do it right - and it finally did, even on platforms like Windows where wchar_t is also 16-bit for historical reasons.

Re:Why Is the Migration to Python 3 Taking So Long? by petre on Thursday November 14, 2019 @04:20PM (#21539565)
I wouldn't call Js a reasonably well designed language but at least it supports Unicode strings.
Re:Why Is the Migration to Python 3 Taking So Long? by flukus on Thursday November 14, 2019 @06:28PM (#21540680)
> Yes, it's expensive to upgrade from Python 2 to Python 3, but it's also expensive for the Python project to maintain 2 versions of Python indefinitely.

No maintaining 2 versions of python is much cheaper, it's only being done in one place compared to the thousands and thousands of python 2 code bases you'd have to convert.

It also only needs bug fixes, there are plenty of people/organisations out there that would be perfectly happy for the language to be unchanging.

Re:Why Is the Migration to Python 3 Taking So Long? by takeda on Friday November 15, 2019 @01:46AM (#21542823)
That's only true if you ignore all packages on PyPi.

It's extremely hard to keep compatibility with Python 2, many authors can't wait to do the support next year, many already dropped.

Re:Why Is the Migration to Python 3 Taking So Long? by flukus on Friday November 15, 2019 @02:23AM (#21542962)
> That's only true if you ignore all packages on PyPi.

Presumably any packages worth maintaining will have far more dependent projects, so it's still far less overall effort.

> It's extremely hard to keep compatibility with Python 2

So don't? I don't think most of the people dragging their feet on the upgrade need or even want new features. A stable python 2 branch with bug fixes and security patches would suffice for most and be ideal for many. Over time the bug fixes should trend to zero and there probably aren't a heap of security issues in python projects anyway.

Re:Why Is the Migration to Python 3 Taking So Long? by daveguy on Thursday November 14, 2019 @04:57PM (#21539905)
> If someone wanted other than the core Python team wants to step up and maintain Python 2, they are free to do so, it's open source.

Only if they name it something completely different from python or py-anything. Guido refuses to allow anyone to just step in to maintain py2.

Tauthon is a project that aims to keep compatability with py2 while adding whatever features of py3 that won't break py2 and to have a maintained py2.

https://github.com/naftaliharris/tauthon

Re:Why Is the Migration to Python 3 Taking So Long? by SignalsFromBob on Thursday November 14, 2019 @03:27PM (#21539058)
I suspect that someone, or a group of people, will step up to unofficially maintain Python 2 for the foreseeable future. It's clear that there are a lot of people using it that either can't easily migrate or are unwilling to do so for the various reasons already discussed in this thread.
Re:Why Is the Migration to Python 3 Taking So Long? by takeda on Thursday November 14, 2019 @04:04PM (#21539392)
I'm sure that for the right money you can find someone.

Don't forget that that person/organization would not only have to maintain python but also all the packages that you will be used.

Re:Why Is the Migration to Python 3 Taking So Long? by JohnFen on Thursday November 14, 2019 @04:14PM (#21539486)
If I encounter Python 2 bugs that matter to me, I can and will fix them myself if needed, and submit or otherwise publish the change.

I'm quite certain I'm not the only one.

Re:Why Is the Migration to Python 3 Taking So Long? by marcus_holmes on Thursday November 14, 2019 @04:59PM (#21539934)
Why not just migrate to 3?

genuinely curious...

Re:Why Is the Migration to Python 3 Taking So Long? by JohnFen on Thursday November 14, 2019 @05:07PM (#21539989)
Because of the amount of work involved in porting my existing Python code. Python 3 doesn't offer any advantages that matter to me, so that's a lot of effort for little gain.
Re:Why Is the Migration to Python 3 Taking So Long? by marcus_holmes on Friday November 15, 2019 @03:31AM (#21543249)
OK, thanks. Good luck with the bug fixing ;)
Re:Why Is the Migration to Python 3 Taking So Long? by JohnFen on Friday November 15, 2019 @11:53AM (#21546400)
I'm not really worried about bugs, because the code I have works well, and I doubt I'm going to do any serious new Python 2 development.
Re:Why Is the Migration to Python 3 Taking So Long? by marcus_holmes on Friday November 15, 2019 @12:12PM (#21546572)
I meant the bugs in your dependencies that you'll have to backport fixes to. But hey, if you're writing bug-free code that'll be easy ;)
Re:Why Is the Migration to Python 3 Taking So Long? by JohnFen on Friday November 15, 2019 @12:23PM (#21546692)
I understood what you meant. What I'm saying is that my existing code works fine, so whatever bugs are in the dependencies are ones that don't affect me. Should I make a code change that surfaces one, then I have the means to deal with it -- but that is almost certainly going to be a rare event, as my Python projects are stable and aren't going to see much change.

I wasn't commenting on how buggy my own code is. Which version of a language I'm using doesn't really affect that variable.

Re:Why Is the Migration to Python 3 Taking So Long? by marcus_holmes on Friday November 15, 2019 @12:39PM (#21546867)
I get that. But the interesting thing about dependencies is how they surface vulnerabilities that can hurt code that works perfectly well. Your current code probably doesn't have many bugs, but includes an unknown number of vulnerabilities from your dependencies. The bad people probably won't bother examining your code for vulnerabilities, but they will be informed of vulnerabilities in popular libs, and then looking for projects that use those versions of those libs is a lot easier than scanning all those projects individually. So you end up having to backport a bunch of fixes to other people's code because that code was popular and came under intense scrutiny.

But I guess you know this, and are OK with the compromises involved. I'll stop here ;)

Re:Why Is the Migration to Python 3 Taking So Long? by JohnFen on Friday November 15, 2019 @12:57PM (#21547042)
> but they will be informed of vulnerabilities in popular libs, and then looking for projects that use those versions of those libs is a lot easier than scanning all those projects individually.

This is true, and if we were talking about code that is exposed to the world at large, then my stance might be different. However, the projects that I've used Python for are not exposed in that way.

Note that I'm talking about personal projects, not work-related ones. At work, I use whatever is required.

Re:Why Is the Migration to Python 3 Taking So Long? by erokar on Thursday November 14, 2019 @12:47PM (#21537539)
Python 3 seems like a bit of a missed opportunity. Since they were introducing breaking changes in the first place, why didn't they go bigger? E.g. make the OOP seem less tacked on, immutable data structures, clean up inconsistencies in the standard library?
Re:Why Is the Migration to Python 3 Taking So Long? by chungy on Thursday November 14, 2019 @12:57PM (#21537659)
Can you describe how OOP feels tacked on? One of the major changes in Python 3 is that new-style classes are the only style of classes.
Re:Why Is the Migration to Python 3 Taking So Long? by erokar on Thursday November 14, 2019 @01:26PM (#21537911)
The nuisance of having to add self as parameter to every class method, no way of enforcing private methods and the mix between methods on objects and functions in the standard library. OO feels more integrated in e.g. Ruby.

About some of the design decisions in Guido's own words: http://python-history.blogspot.com/2009/02/adding-support-fo...

Re:Why Is the Migration to Python 3 Taking So Long? by uranusjr on Thursday November 14, 2019 @03:27PM (#21539059)
I’ve seen a lot of people taking issue with the self argument. Am I crazy to actually love it as a feature? I pulled out a lot of my hairs when I first started OOP (Java) trying to gork `this`, and I remember myself thinking “why didn’t everybody just do this” when I saw how Python declare methods. And I still think that’s a good idea now. So much easier to keep my sanity than using JavaScript’s bind.
Re:Why Is the Migration to Python 3 Taking So Long? by gowld on Thursday November 14, 2019 @04:10PM (#21539459)
What's weird is that it's half baked

   def foo(self):
instead of a more logical:

   def self.foo():
to match the calling syntax.
Re:Why Is the Migration to Python 3 Taking So Long? by keypusher on Thursday November 14, 2019 @05:06PM (#21539984)
I don't think you understand what is actually going on under the hood here, at all. Methods are member functions of a class, and must be invoked on an object.

  someInstance.foo()
When invoking a method from within the class, you still need a reference to the object the method will be invoked on. In python, the reference is passed implicitly as the first argument, and usually called self. That has nothing to do with the method name or signature itself, and calling the method self.foo() would result in calling it like

  someInstance.self.foo()
for cases when you aren't referencing the function from within the class, which would be even more confusing.
Re:Why Is the Migration to Python 3 Taking So Long? by biggestdecision on Thursday November 14, 2019 @06:05PM (#21540497)
The syntax of a language is an abstraction over what is actually going on under the hood. There's no reason python couldn't have designed their OOP abstraction more elegantly.
Re:Why Is the Migration to Python 3 Taking So Long? by dragonwriter on Friday November 15, 2019 @03:31AM (#21543251)
> There's no reason python couldn't have designed their OOP abstraction more elegantly.

Sure there is: consistency. If member functions on an object that happens to be a class (i.e., methods) did magic transformations that member functions of other objects did not do, the mental overhead to understand Python code would be higher, and the ability to build custom general abstractions would be weaker.

It would perhaps make the simplest cases microscopically easier, but at the expense of making the already hard things more confusing and difficult to wrap with generalities.

Most statically-typed OOPLs don't have first-class classes that are just normal objects, so this isn't an issue because the things that enables aren't available; other dynamic languages may use models where methods aren't data members of classes (e.g., Ruby where methods are associated with classes, but not as instance members which, in Ruby, wouldn't be externally accessible—while Ruby classes are objects, the ability to hold methods is a special power of Ruby classes/modules compared to other objects, not just having instance members. This is one way Ruby's model is more complex than Python’s, and it definitely bites you in terms of seeking general solutions some times..)

Re:Why Is the Migration to Python 3 Taking So Long? by joshuamorton on Thursday November 14, 2019 @07:32PM (#21541151)
Why is self.foo more elegant? It's very rare that you'll call a given method as self.foo, and there's a slew of complications that come with such a syntax (the declaration grammar is more complex, `self` is now special, etc.)

It's true that languages are abstractions, but not all abstractions are useful.

Re:Why Is the Migration to Python 3 Taking So Long? by int_19h on Friday November 15, 2019 @03:16AM (#21543177)
It doesn't have to treat "self" as a special keyword - it just has to desugar "foo.bar(x, y)" into "bar(foo, x, y)". There are some other languages that do that - e.g. in F#, you write:

   member this.foo(x, y) = ...
Again, "this" is just an identifier here, and doesn't have any special meaning.

It's more elegant firstly because it follow use, and secondly because it means that "def foo(x)" has the same meaning both inside and outside of a class declaration - it's just a function, and there's nothing special about its first argument. As it is, we need stuff like @staticmethod and @classmethod. It's especially annoying when you have class attributes that happen to reference a function, because conversion from functions to methods is a runtime thing - so you have to remember to wrap those in staticmethod() as well.

Re:Why Is the Migration to Python 3 Taking So Long? by dragonwriter on Friday November 15, 2019 @03:38AM (#21543280)
> As it is, we need stuff like @staticmethod and @classmethod

You would need those even with your suggestion (except you could drop @staticmethod if you add another layer of magic so that methods declared without an leading identifier were assumes static; you'd still need @classmethod some equivalent mechanism to distinguish which non-static methods were class vs instance methods.)

Re:Why Is the Migration to Python 3 Taking So Long? by int_19h on Friday November 15, 2019 @03:54AM (#21543352)
My suggestion implied removing the descriptor-based "magic" on regular functions that make them behave as methods when accessed using dot-member syntax, and instead making the "def self.foo" syntax produce a special kind of function that would have that behavior. @staticmethod today basically just suppresses that special behavior on regular functions, so it wouldn't be needed in this case. But yeah, we'd still need @classmethod.
Re:Why Is the Migration to Python 3 Taking So Long? by joshuamorton on Friday November 15, 2019 @03:49AM (#21543323)
> It's more elegant firstly because it follow use

No it doesn't. Currently `def foo(self): pass` is called as `instance.foo()`. You're suggesting that `def self.foo(): pass` would be called as `instance.foo()`, except now it looks like self and instance are syntactically related in ways that they aren't.

> Again, "this" is just an identifier here, and doesn't have any special meaning.

But the grammar is no longer LL(1), and you have weird conditionally valid syntax, like `.` in a function name is valid only in a class block.

> "def foo(x)" has the same meaning both inside and outside of a class declaration

This is a stretch, especially since you're now optimizing for the uncommon case. Staticmethods are rare compared to instance methods (I'll go further and claim that static methods are an antipattern in python, modules are valid namespaces, you can stick a function in a module and couple it to a class also defined in that module and nothing bad will happen. Banning staticmethods entirely doesn't reduce expressiveness). Aligning staticmethods with functions, instead of aligning instance methods with functions (as python does currently) encourages you to do the wrong thing.

> classmethod

Your changes don't affect classmethod at all, if anything they'd make classmethod more of a special case. How do you signal that `self.foo()` takes `self` as the class instead of the instance?

> It's especially annoying when you have class attributes that happen to reference a function, because conversion from functions to methods is a runtime thing - so you have to remember to wrap those in staticmethod() as well.

What do you mean? Like

    class Foo:
        a = Foo.func()
        @staticmethod
        def func():
            return 1
I'll say again: staticmethods are an antipattern in python:

    def func()
        return 1

    class Foo:
        a = func()
works just as well, better in fact. Modules are great namespaces. Classes are more than namespaces, and if all you need is a namespace, you shouldn't use a class.

> because conversion from functions to methods is a runtime thing

I'd also quibble with this: it's a binding thing.

    class Foo:
        a = Foo.foo(None)
        def foo(self):
            return 1
will work, and if you check, type(Foo.foo) is still just `function`, its only when you create an instance of Foo that the function `foo` is bound to the instance, and when that is done, the bound `foo` is converted to a method object. This was different in python2, where Foo.foo and instance.foo were both "instancemethod" objects, but in python3, Foo.foo is a plain old function, and instance.foo is a method.

Specifically this means that if you can get your hands on the `method` constructor (like with `type(instance.method)`), you can then do silly things like

    class A():
      def foo(self): pass
    instance = A()
    def f(self): return 5
    assert instance.func() == 5
and this will work. You'll have bound the function to the instance. Of course, if you stick an attribute on `instance` (or `A`), and reference `self.attribute` in the function, this will still work. (this also lets you do things like bind a given instance of a function to a different instance of the class, but that's because the method constructor is essentially just partial with some bookkeeping for class information)
Re:Why Is the Migration to Python 3 Taking So Long? by int_19h on Friday November 15, 2019 @04:18AM (#21543470)
Python grammar is not LL(1) in general; just look at set and dict literals. This is really no different than ":" after an expression being legal inside a dict literal (and how you know that it is a dict literal).

But also, there's no reason to make those legal only inside classes. All it needs to do is make "def foo.bar" produce a different type of function, that has the method descriptor-producing behavior that is currently implemented directly on regular functions.

As far as less vs more common case - I think it's more important to optimize for obviousness and consistency. If "def foo" is a function, it should always be a function, and functions should behave the same in all contexts. They currently don't - given class C and its instance I, C.f is not the same object as I.f, and only one of those two is what "def" actually produced.

What I meant by function references inside classes is this:

   class Foo:
      pass

   Foo.bar = lambda: 123
   foo = Foo()
   print(foo.bar())
This blows up with "TypeError: <lambda>() takes 0 positional arguments but 1 was given", because lambda is of type "function", and it gets the magic treatment when it's read as a member of the instance. So you have to do this:

   Foo.bar = staticmethod(lambda: 123)
and even then this is only possible when you know that the value is going to end up as a class attribute. Sometimes, you do not - you pass a value to some public function somewhere, and it ends up stashed away as a class attribute internally. And it all works great, until you pass a value that just happened to be another function or lambda.

On the other hand, this only applies to objects of type "function", not all callables. So e.g. this is okay:

   Foo.bar = functools.partial(lambda x: x, 123)
because what partial() returns is not a function. Conversely, this means that you can't use partial() to define methods, which can be downright annoying at times. Suppose you have:

   class Foo:
      def frob(self, x, y): ...
and you want to define some helper methods for preset combinations of x and y. You'd think this would work:

   class Foo:
      def frob(self, x, y): ...
      frob_xyzzy = functools.partial(frob, x=1, y=2)
      frob_whammo = functools.partial(frob, x=3, y=4)
except it doesn't - while frob_xyzzy() and frob_whammo() both have the explicit "self" argument, they aren't "proper" functions, and thus that argument doesn't get treated as the implicit receiver:

   foo = Foo()
   foo.frob(x=0, y=0)    # okay
   foo.frob_xyzzy()      # TypeError: frob() missing 1 required positional argument: 'self' 
   foo.frob_whammo(foo)  # okay!
Which is to say, this all is a mess of special cases. You can argue that this all isn't really observable in the "common case" - the problem is that, as software grows more complex, the uncommon cases become common enough that you have to deal them regularly, and then those inconsistencies add even more complexity into the mix that you have to deal with - just when you already thought you had your plate full.
Re:Why Is the Migration to Python 3 Taking So Long? by joshuamorton on Friday November 15, 2019 @04:43AM (#21543584)
> Python grammar is not LL(1) in general; just look at set and dict literals. This is really no different than ":" after an expression being legal inside a dict literal (and how you know that it is a dict literal).

Yes it is[0]. LL(1) Grammars can still be recursive, they just can't change the parsing rules based on distant context.

> As far as less vs more common case - I think it's more important to optimize for obviousness and consistency

Yes, but having the "easiest" thing you do:

    class Foo:
        def bar():
            pass
silently do a usually unwanted thing (create a staticmethod) instead of an obviously wrong thing (raise an error) isn't obvious. It's building a footgun into the language.

The rest of your comment complains about inconsistencies of how python converts various callables to methods. This is a fairly valid and interesting complaint, but has nothing to do with syntax, it is solely a semantic complaint that would be solved by having class creation treat all attributes that are callables as functions. In fact, you could customize class creation yourself this way using __new__, no syntactic changes required.

> as software grows more complex, the uncommon cases become common enough that you have to deal them regularly

While this is true, I think you vastly overestimate how common these constructs are. Like, you're in the realm of "this doesn't appear on github" levels of uncommon.

Personally, again, I think "you can't use partial() to define methods" is a very good thing: if you're doing this, you're into weird metaprogramming land. Its not any harder to, for example, write out

    class Foo:
      def frob(self, x, y): ...
      def frob_xyzzy(self): return self.frob(x=1, y=2)
      def frob_whammo(self): return self.frob(x=3, y=4)
unless you're doing weird metaprogrammy magic and then, as someone who does a lot of weird metaprogrammy magic

1. You deserve what you get

2. You can invoke deeper magic to solve these problems

[0]: https://discuss.python.org/t/switch-pythons-parsing-tech-to-...

Re:Why Is the Migration to Python 3 Taking So Long? by int_19h on Friday November 15, 2019 @06:31PM (#21549790)
Why is it an unwanted thing? By the same logic that demands "self" to be explicit, if you don't specify "self", then you explicitly don't want the method to be an instance method - seems very straightforward to me. And it's still invokable via instance member access, so the user of the class is none the wiser. Where's the footgun?

My complaint is of course more complicated than the syntax alone. I'm just saying that a distinctive syntax for self-as-receiver could be used to drive other changes that would make things more intuitive and self-consistent overall. And, of course, any discussion about "elegance" is going to be inherently subjective.

With respect to commonality of various constructs - this is all from personal experience writing Python code (for a project that is hosted on GitHub, by the way). It doesn't require particularly fancy code to trip that wire in general - it just requires code that tries to be generic, i.e. not make more assumptions that it needs to about the types of values that flow through it. Python classes break that genericity by treating functions, and only functions, in a special way whenever they flow through class attributes. This is particularly egregious in a language where every object is potentially callable, and non-function callables are very common; so functions really aren't all that special in general - except for that one case.

With partial() specifically, of course you can avoid that in this manner. But why would you, if it works with regular functions? I prefer it over defs, not just because it's more concise and avoids repeating things, but because it's also clearer - when you see partial(), it immediately tells you that it's a simple alias, nothing else.

But regardless, it's a function that has a certain documented behavior, and common sense would dictate that this behavior works the same for methods as well as functions. That it doesn't is not an intentional limitation of partial() - it's an unfortunate quirk of the design of methods themselves. And if you don't know exactly how functions become methods in Python, you wouldn't have any reason to expect the behavior that it exhibits. That's why the docs for partial() have to spell it out explicitly: "partial objects defined in classes behave like static methods and do not transform into bound methods during instance attribute look-up" - because that's not a reasonable default assumption!

The bigger problem is that every library that offers a generic wrapper callable has to add the same clause to its docs, because they're all affected in the same way. And if they don't document it, and you use, say, a decorator from a library - how do you know whether the fact that it returns a function and not some other callable is part of the contract that you can rely on, or an implementation detail? Conversely, whenever you implement a decorator, you have to be cognizant that changing the type of the return value from/to plain function can be a breaking change for your clients - and that is even less obvious.

Re:Why Is the Migration to Python 3 Taking So Long? by joshuamorton on Friday November 15, 2019 @06:47PM (#21549869)
> Why is it an unwanted thing?

Let's take the following code snippet as an example:

    class Foo:
      def bar(val):
        foo = val
I claim that most of the time this is a mistake, and the author would have preferred `def bar(self, val): self.foo = val`. In current python, this will raise an exception when called. In your proposed python, this will silently do nothing, possibly leaving the instance in an invalid state. This is a footgun. I admit the example is contrived, but forgetting `self` is a thing I've seen happen, and having it fail loudly is preferable to having it do something likely unintended. Again, if someone wants to do the unusual thing, `@staticmethod` is still around.

> With partial() specifically, of course you can avoid that in this manner. But why would you, if it works with regular functions?

Simply: because I'd prefer it if functions look like functions. Understanding that `def x` is a callable is easier than trying to discern if `x = foo(other_thing)` results in x being callable or not, where it does for some values of `foo`, but not for others. Which isn't to say that python shouldn't make this change, I think I mostly agree with your complaint, I just probably wouldn't take advantage of it.

> My complaint is of course more complicated than the syntax alone.

To be frank, I don't see any connection between your syntactical suggestions and your semantic ones. They seem to be entirely orthogonal.

Re:Why Is the Migration to Python 3 Taking So Long? by Doxin on Friday November 15, 2019 @10:39AM (#21545687)
The thing is that that doesn't really match the calling syntax, it matches the syntactic sugar for the calling syntax. Whenever you do

    thing_instance.foo(bar, baz)
you're secretly calling

    Thing.foo(thing_instance, bar, baz)
Which succinctly explains where the self argument comes from.
Re:Why Is the Migration to Python 3 Taking So Long? by duahncjak on Thursday November 14, 2019 @04:21PM (#21539571)
Wow, this is a lot more intuitive. gowld for BDFL!
Re:Why Is the Migration to Python 3 Taking So Long? by sweeneyrod on Thursday November 14, 2019 @02:41PM (#21538627)
The first two of those are explicit design decisions: "explicit is better than implicit" and "we're all consenting adults" respectively.
Re:Why Is the Migration to Python 3 Taking So Long? by smacktoward on Thursday November 14, 2019 @03:09PM (#21538903)
There's a fine line between "explicit is good because it means how things behave is obvious" and "explicit is bad because it means typing the same boilerplate over and over again."

Not saying Python fell on the wrong side of that line, just that it's an easy line to end up on the wrong side of.

Re:Why Is the Migration to Python 3 Taking So Long? by ForHackernews on Thursday November 14, 2019 @04:00PM (#21539350)
You're free to use `_` (or whatever) instead of `self`, if you find `self` to be much repetitive boilerplate. It's only a convention.
Re:Why Is the Migration to Python 3 Taking So Long? by gowld on Thursday November 14, 2019 @04:11PM (#21539464)
Sadly the linters went for `self`.
Re:Why Is the Migration to Python 3 Taking So Long? by erokar on Thursday November 14, 2019 @03:01PM (#21538816)
Most things in a language are explicit design decisions. Doesn't automatically make them good decisions.

Actually Python is one of my favorite programming languages, probably the language with the closest mapping to how I naturally think about a problem. I really like it. But I'm also willing to admit it has some warts, as does any language.

Re:Why Is the Migration to Python 3 Taking So Long? by ForHackernews on Thursday November 14, 2019 @04:03PM (#21539384)
Python has warts, but IMHO it's weird to identify valid design choices, with pros and cons on each side, as "warts".

If I were listing Python warts, I'd point to things like single-element tuples (1,), the `datetime` support (timezone-naive datetimes are an ambiguous disaster), or the cpython Global Interpreter Lock.

Re:Why Is the Migration to Python 3 Taking So Long? by mixmastamyk on Friday November 15, 2019 @12:49AM (#21542560)
Yep, complaining about self is kinda silly when there are real things to complain about.

My editor supports snippets so moderate python boilerplate is not a problem.

Re:Why Is the Migration to Python 3 Taking So Long? by progval on Thursday November 14, 2019 @05:14PM (#21540049)
> The nuisance of having to add self as parameter to every class method

This was done intentionnaly, because "Explicit is better than implicit". It also has some uses, eg. if you want to do this:

    class Foo:
        def inject_bar(self):
            def new_bar(self2):
                pass # you can refer to both 'self' and 'self2 here
            other_object.bar = new_bar
It's rare, but it has its uses.
Re:Why Is the Migration to Python 3 Taking So Long? by tomp on Thursday November 14, 2019 @05:30PM (#21540202)
> "Explicit is better than implicit"

Too bad Python breaks this "commandment" pretty much whenever it wants to.

Re:Why Is the Migration to Python 3 Taking So Long? by progval on Thursday November 14, 2019 @05:46PM (#21540337)
Yeah, The Zen of Python has commandments to justify pretty much anything. eg. "Simple is better than complex." or "Readability counts." when you want something to be implicit
Re:Why Is the Migration to Python 3 Taking So Long? by rectangletangle on Friday November 15, 2019 @12:16AM (#21542379)
"Practicality beats purity"
Re:Why Is the Migration to Python 3 Taking So Long? by gpderetta on Thursday November 14, 2019 @04:06PM (#21539416)
FWIW, I wish 'this' were explicit in C++.
Re:Why Is the Migration to Python 3 Taking So Long? by viraptor on Thursday November 14, 2019 @02:26PM (#21538497)
You know that double underscore is basically making a method private, right? You can work around it to access the method anyway, but you can do that as well with Ruby.
Re:Why Is the Migration to Python 3 Taking So Long? by takeda on Thursday November 14, 2019 @04:08PM (#21539435)
first is a design decision, felt weird at first but after time I kind of like it, there's less magic behavior happening.

The second is not true, if you add methods with double underscore (also design decision) they do behave like private. The real method name will be randomly generated so you won't get conflicts, and you can still access it for debugging purposes.

Re:Why Is the Migration to Python 3 Taking So Long? by dragonwriter on Thursday November 14, 2019 @01:37PM (#21538021)
I think for some people having the receiver as an explicit parameter of methods rather than references through a special syntactic variable bothers some people and makes it look to them like a procedural language playing OO, though I personally think it's the most clear representation of what every class-based OO language actually does operationally, since methods are attached to a class and take a reference to the instance on which they are invoked.
Re:Why Is the Migration to Python 3 Taking So Long? by AnimalMuppet on Thursday November 14, 2019 @04:48PM (#21539844)
It may in fact be what every class-based OO language actually does operationally. But having the OO language do that for you is, to me, one of the lines that separates them from "a procedural language playing OO".
Re:Why Is the Migration to Python 3 Taking So Long? by dragonwriter on Thursday November 14, 2019 @08:22PM (#21541426)
To me, it makes sense for a class-based OO language with first-class functions and (unlike, e.g., Java) available direct external access to data members to do what Python does because it reinforces the distinction between function members and methods.

Perhaps more importantly, it makes even more sense in a language like Python where classes are (unlike many, especially statically-typed, class-based OO languages) first class objects to do what Python does, because of the relation of methods to classes. It also, to me. makes unbound/bound methods slightly more intuitive.

Now, I too was initially thrown by it because I'd used a bunch of OO languages that did it the other way first, and for quite a long time.

Re:Why Is the Migration to Python 3 Taking So Long? by int_19h on Friday November 15, 2019 @03:19AM (#21543192)
How would you describe OO languages which only have multimethods, then? Say, Dylan?
Re:Why Is the Migration to Python 3 Taking So Long? by AnimalMuppet on Friday November 15, 2019 @08:31PM (#21550357)
Don't know enough to say.
Re:Why Is the Migration to Python 3 Taking So Long? by CoolGuySteve on Thursday November 14, 2019 @01:19PM (#21537850)
I myself, speaking for my self and only my self find that, in regards to myself, the redundant self keyword, in my self's opinion, is somewhat selfish and easy for my self to accidentally omit. Self.
Re:Why Is the Migration to Python 3 Taking So Long? by enragedcacti on Thursday November 14, 2019 @01:37PM (#21538027)
I personally really like the self keyword after spending some time reading code in Java where `this` is optional. Having to reference self makes it more clear where data is coming from and makes navigating an unfamiliar code base much easier. I'm a fan of forcing devs to acknowledge when they are accessing or manipulating mutable object state.

Separate from that, I think that would be a much bigger breaking change than you think. __setattr__ and __setattribute__ means that self.y doesn't necessarily refer to a traditional attribute so without self you could end up with either:

1. `x = y` where the expression `y` executes code

or

2. `x = y` where `x = ???` and `x = self.y` where `x = self.__setattr__('y')`.

That said, I do think the language could use something to reduce the size of __init__() since

self.arg1 = arg1

self.arg2 = arg2

self.arg3 = arg3

...

can get pretty verbose

Re:Why Is the Migration to Python 3 Taking So Long? by coldtea on Thursday November 14, 2019 @02:43PM (#21538648)
>Having to reference self makes it more clear where data is coming from and makes navigating an unfamiliar code base much easier.

I don't understand this. Aside from people seeing an OOP for the first time in their life, are they getting confused about where "this" comes from?

How would an implicit "self" a la "this" make it any less understandable where the data come from?

How is passing self making "navigating an unfamiliar code base much easier"? Aside from total newbs who see an OO codebase with an implicit instance variable for the first time?

Re:Why Is the Migration to Python 3 Taking So Long? by fireflash38 on Thursday November 14, 2019 @02:57PM (#21538781)
I believe the original commenter was more referring to the lack of 'this' usage in Java.

So instead of having:

    this.x = y
People tend to do:

    x = y
Which isn't always the most clear that it's referencing an instance variable rather than a scoped variable, especially if you see it midway through a method.
Re:Why Is the Migration to Python 3 Taking So Long? by coldtea on Thursday November 14, 2019 @03:49PM (#21539241)
A, alright then. I'd go with making this mandatory in that case.
Re:Why Is the Migration to Python 3 Taking So Long? by dfinninger on Thursday November 14, 2019 @02:07PM (#21538319)
To your last point, check out Dataclasses[1].

    @dataclass
    class Foo:
        arg1: str
        arg2: int
        arg3: int = 5  # default value
I use them a lot in my 3.7+ projects. It helps reduce the boilerplate for typical classes. (Where for me, typical classes are a 1:1 mapping of inputs to attributes)

And if you need to compute some values at object initialization, then they have a __post_init__() hook you can use [2].

[1] https://docs.python.org/3/library/dataclasses.html [2] https://docs.python.org/3/library/dataclasses.html#post-init...

Re:Why Is the Migration to Python 3 Taking So Long? by gowld on Thursday November 14, 2019 @04:14PM (#21539487)
Java fields are declared in the same lexical scope as their use sites (except for inherited fields, but Python has the same magic in that case.)
Re:Why Is the Migration to Python 3 Taking So Long? by timw4mail on Thursday November 14, 2019 @01:31PM (#21537960)
My experience with Python is a little lacking, but doesn't the self keyword mean the difference between an instance method, and a static method?

Rust does the same thing - with self, it's an instance method, without, it's a static method.

Re:Why Is the Migration to Python 3 Taking So Long? by dfinninger on Thursday November 14, 2019 @02:10PM (#21538347)
Python has an "@staticmethod" decorator you can put on a function inside of a class definition. Then you don't need to pass "self" as a first arg.

https://www.geeksforgeeks.org/class-method-vs-static-method-...

Re:Why Is the Migration to Python 3 Taking So Long? by int_19h on Friday November 15, 2019 @03:29AM (#21543236)
"self" is not a keyword in Python, just a convention.

Any function inside a class declaration becomes an instance method, with its first argument becoming the explicit receiver. You have to use @staticmethod to prevent that (or @classmethod to get the class as the first argument, instead of the instance).

Furthermore, this behavior is not parse-time, but runtime. The "def" statement that defines a function produces a plain function object, regardless of whether it's inside a class or not. Once the class finishes defining, the function is still a function - which is why C.f gives you a plain instance that can be called by passing "self" explicitly as an argument.

However, Python allows objects to provide special behavior for themselves whenever they're retrieved via a member of some class - that is, when you write something like x.y, after y is retrieved from x, it gets the opportunity to peek at x, and substitute itself with something else. Function objects in Python (here I mean specifically the type of objects created with "def" and "lambda", not just any callable) use this feature to convert themselves to bound methods. So, when you say x.f, after retrieving f, f itself is asked if it wants to substitute something else in its place - and it returns a new callable object m, such that m(y) calls f(x, y). That's what makes x.f(y) work.

Re:Why Is the Migration to Python 3 Taking So Long? by btown on Thursday November 14, 2019 @01:38PM (#21538034)
Self lets you do really cool things though. For instance, you can monkey-patch with `def override_method(arg_that_will_get_self, *args): pass; Class.method = override_method` after Class is defined. Python lets you have all the dynamism of Ruby without letting you go too crazy with DSLs - which is the perfect balance IMO.
Re:Why Is the Migration to Python 3 Taking So Long? by zabzonk on Thursday November 14, 2019 @01:27PM (#21537919)
To be pedantic "self" is not a keyword.
Re:Why Is the Migration to Python 3 Taking So Long? by WorldMaker on Thursday November 14, 2019 @02:18PM (#21538417)
Worse than that not being a keyword, `self` isn't special at all, it's a naming convention that can be freely broken. Python codebases using `this` instead of `self` exist. Codebases that mix the two depending on who wrote which method in a class exist. I believe I saw `it` used once somewhere as the name for that parameter. I'm sure there are codebases with even crazier horrors for first argument names in class methods out there in the depths of corporate machines.
Re:Why Is the Migration to Python 3 Taking So Long? by dragonwriter on Thursday November 14, 2019 @01:41PM (#21538071)
Python doesn't have a self keyword, redundant or otherwise.

In fact, that's a key difference between Python and many other class-based OO languages.

I'm not sure whether that (and the associated need to make the receiver an explicit parameter—conventionally, though this is not required, named “self” in instance methods—in method definitions) is your problem, or if your problem is that (unlike some, but fewer than the previous difference, OO languages) you can't omit explicitly naming receiver in references to its own instance variables in an instance methods, making instance variable reference syntactically distinct from local variable references.

Re:Why Is the Migration to Python 3 Taking So Long? by kzrdude on Thursday November 14, 2019 @04:25PM (#21539604)
Modern Python lacks coherent design:

How do you define enums? with a superclass.

How do you define data classes? With a class decorator.

And then there's metaclasses too.

Re:Why Is the Migration to Python 3 Taking So Long? by joshuamorton on Thursday November 14, 2019 @07:38PM (#21541178)
Enums are technically defined with a metaclass, as are abstract base classes and most other weird special classes (but in all cases you access the metaclass by subclassing something). Dataclasses are the one exception, and they do this for pragmatic reasons: multiple metaclasses are tricky. So a decorator allows the existence of an abstract dataclass, for example.
Re:Why Is the Migration to Python 3 Taking So Long? by dividuum on Thursday November 14, 2019 @02:23PM (#21538472)
> The only real killer feature of Python3 is the async programming model.

I understand that this is one of the major features, but I personally never saw the appeal, given that gevent exists and in my experience works well most of the time. It also allows me to multiplex IO operations and doesn't rely on new syntax. I'm probably missing something?

Re:Why Is the Migration to Python 3 Taking So Long? by d0mine on Thursday November 14, 2019 @05:07PM (#21539995)
In gevent, any call may behave like an implicit "goto". Here's why "goto" is bad https://vorpus.org/blog/notes-on-structured-concurrency-or-g... (the link is stolen from @hermod's comment above)
Re:Why Is the Migration to Python 3 Taking So Long? by jlokier on Thursday November 14, 2019 @06:28PM (#21540682)
I think the nursery construct described in that link looks a lot like par blocks in Occam, Handel-C and XMOS XC.
Re:Why Is the Migration to Python 3 Taking So Long? by Scramblejams on Thursday November 14, 2019 @08:40PM (#21541523)
I find it much easier to reason about my async Python code when the async yield points are explicit. If every line can potentially yield to another async task, I find myself thinking long and hard about a lot of those lines.
Re:Why Is the Migration to Python 3 Taking So Long? by epx on Thursday November 14, 2019 @04:14PM (#21539502)
For me the major gain in Py3 is exactly the sane handling of strings, that fixes the major flaw of Py2: weaking the String type to make the migration to UnicodeStrings "easy".
Re:Why Is the Migration to Python 3 Taking So Long? by meowface on Thursday November 14, 2019 @09:08PM (#21541652)
It's funny, because I consider asyncio (and derivatives like curio) to be the worst part of Python 3. There are plenty of other compelling reasons to move over. No, none of them revolutionize the language, but there are fewer warts and cleaner ways of doing many things.
Re:Why Is the Migration to Python 3 Taking So Long? by mxcrossb on Thursday November 14, 2019 @01:15PM (#21537822)
On the topic of not enough carrot, I’m curious how impactful the end of support for python2 will be. How many programs stuck in python2 are encountering bugs in the runtime?
Re:Why Is the Migration to Python 3 Taking So Long? by carapace on Thursday November 14, 2019 @02:02PM (#21538267)
I actually find this aspect of the whole thing exciting, perhaps paradoxically. Now that Python 2 is static the runtime can become asymptotically bug-free. Meaning that, if you only change it to fix bugs (as opposed to introducing new syntax|semantics) it's going to approach perfection.
Re:Why Is the Migration to Python 3 Taking So Long? by d0mine on Thursday November 14, 2019 @05:10PM (#21540017)
You are assuming that fixing bugs introduces less new bugs.
Re:Why Is the Migration to Python 3 Taking So Long? by joshuamorton on Thursday November 14, 2019 @03:37PM (#21539142)
Who will do that though?
Re:Why Is the Migration to Python 3 Taking So Long? by carapace on Thursday November 14, 2019 @04:41PM (#21539760)
Re:Why Is the Migration to Python 3 Taking So Long? by downerending on Thursday November 14, 2019 @04:48PM (#21539838)
I've considered taking it on. If there were enough money in it, I'd very seriously consider it. It's a very good language.
Re:Why Is the Migration to Python 3 Taking So Long? by arbie on Thursday November 14, 2019 @06:31PM (#21540708)
In ten years, there will be serious money in it as enterprise codebases need to be renewed.
Re:Why Is the Migration to Python 3 Taking So Long? by takeda on Thursday November 14, 2019 @04:14PM (#21539494)
Python itself won't be as much affected, what will affect you most are your dependencies. Imagine using a library and running in some kind of bug. You check newer version, looks like that bug was fixed, but the library now only works on python 3.6+. What will you do?
Re:Why Is the Migration to Python 3 Taking So Long? by JohnFen on Thursday November 14, 2019 @06:45PM (#21540824)
Backport the fix from 3.6, or just implement a fix yourself?
Re:Why Is the Migration to Python 3 Taking So Long? by takeda on Thursday November 14, 2019 @09:23PM (#21541710)
Yes, that's one option it will be feasible initially but it will get exponentially harder.
Re:Why Is the Migration to Python 3 Taking So Long? by x0x0 on Thursday November 14, 2019 @03:28PM (#21539070)
And the side-effect of an endless trail of shit to deal with. I write primarily ML code so until 3.5 or 3.6 python 3 offered me almost nothing better. It did, however, make managing environments even more of a mess. I quite frankly resented having to deal with code in both, swapping back and forth between python2, python3, pip2, pip3, etc.
Re:Why Is the Migration to Python 3 Taking So Long? by rtpg on Friday November 15, 2019 @02:02AM (#21542881)
- format strings

- mandatory keyword arguments

- multi-dict splatting

- nicer yield semantics for generators

- Fixing system-specific encoding ambiguities

- dataclasses

- inline type annotations

- better metaclass support

- more introspection tooling

- pathlib (for nicer path handling)

- mocking pulled into the standard library in a cleaner way

- stable ABIs for extensions

- secrets handling

- ellipsis instead of pass (yeah who cares but I care)

- lots of standard lib API cleanup

All of this is very helpful for making clean applications. But I would say it's _very_ helpful for making good libraries as well. This stuff is about having a strong language foundation to avoid plain weirdness like the click issue .

Obviously it doesn't kill all of them, but there used to be even more of that kind of thing all the time. Library issues would basically get exported to its users, all basically due to language problems.

Re:Why Is the Migration to Python 3 Taking So Long? by oarabbus_ on Thursday November 14, 2019 @05:38PM (#21540279)
I ran into an issue recently specific to Pandas and python3 with unicode.

pd.read_excel(filepath) will read an entire dataset even if it contains unicode characters.

pd.ExcelFile() silently drops(!!) unicode rows. The resulting object will simply skip unicode-containing rows (in ANY column) them without even a warning.

For example, if you had an excel file:

word

---

"hello"

"hello"

你早

你早

"hello"

then pd.read_excel() would give you a dataframe with 5 rows. ExcelFile() on the other hand would return (silently!) a dataframe with only the first two and the last row.

Maybe this is a pandas issue, not a python issue, but it was really horrendous to debug for such a long time only to realize this was the issue.

Re:Why Is the Migration to Python 3 Taking So Long? by j88439h84 on Thursday November 14, 2019 @08:16PM (#21541391)
Is there an issue for this in the bug tracker?
Re:Why Is the Migration to Python 3 Taking So Long? by oarabbus_ on Friday November 15, 2019 @03:24AM (#21543213)
I searched, and this is the closest thing (https://github.com/pandas-dev/pandas/issues/11503) but it is not the issue I experienced.

I'm not sure how to submit a bug report, to be honest.

Re:Why Is the Migration to Python 3 Taking So Long? by snagglegaggle on Thursday November 14, 2019 @12:57PM (#21537656)
The main change people cite is the UTF-8 "support" but frankly it seems like far more pomp and circumstance than is necessary. Appropriate code point handling could have been provided and everything left as it was. And when you get rid of that, there's not that much left that is breaking.
Re:Why Is the Migration to Python 3 Taking So Long? by CoolGuySteve on Thursday November 14, 2019 @01:43PM (#21538085)
I find the stronger differentiation between bytes and strings leads to a lot of gotchas, like when I forget to encode bytes or pass a string where bytes are expected.

I understand why it's the way it is, but when it comes the the typical unixy things I need to do shuffling of files around, tar'ing stuff, etc, it definitely trips me up more than I'd wish.

Re:Why Is the Migration to Python 3 Taking So Long? by mkesper on Thursday November 14, 2019 @02:33PM (#21538556)
You at least notice it's wrong. In Python2 sometimes 'it worked' until it broke and you had to figure out why.
Re:Why Is the Migration to Python 3 Taking So Long? by snagglegaggle on Thursday November 14, 2019 @03:19PM (#21538995)
See, it just broke when UTF-8 was interpreted as ASCII. It's entirely possible to treat bytes as bytes and leave encoding out of it for the vast majority of programs. If you're dealing with text editing and so on, then you know you need to be UTF-8 aware, and the broken programs would still be broken in either language.

The visibility of the errors is a minor point, but I think it more appropriate that it be solved by e.g. the windowing toolkit API.

Re:Why Is the Migration to Python 3 Taking So Long? by stefco_ on Thursday November 14, 2019 @04:41PM (#21539770)
> the broken programs would still be broken in either language.

You need to slap a decode anyway on reads from subprocesses in python3, and files open in Unicode mode by default. Wouldn't that fix the majority of silly UTF-8 compat bugs? Or am I missing a class of bugs that's not avoided automatically by python3 strings?

Re:Why Is the Migration to Python 3 Taking So Long? by snagglegaggle on Thursday November 14, 2019 @05:12PM (#21540033)
Well, the summary of the argument is that the python3 UTF-8 does not actually solve the fundamental problem of multiple encoding formats existing. Think: Do you know that the process actually returns UTF-8, or that the file is actually encoded in UTF-8? No, you're just guessing. This puts people in the habit of attempting to turn everything into UTF-8 which could happen automatically and not require so much boilerplate.

On the other end, most programs don't actually care what the data encoding is. They just move it.

Re:Why Is the Migration to Python 3 Taking So Long? by int_19h on Friday November 15, 2019 @03:34AM (#21543261)
> Think: Do you know that the process actually returns UTF-8, or that the file is actually encoded in UTF-8? No, you're just guessing.

Well, no, not really. You go read the docs and try to find out. Most of the time, there is a definitive encoding - if there weren't, a lot more things would be broken. Sometimes, it is not guaranteed, even though de facto that is the case - and this highlights broken interface specifications. When it is truly unknown, you explicitly treat it as raw bytes.

And the good thing about Python 3 is that it forces you to think about this. In Python 2, most of the time, data processing code can be hacked together, and it "just works", right until the point the input happens to include something unanticipated. Like, say, the word "naïve".

> On the other end, most programs don't actually care what the data encoding is. They just move it.

It doesn't necessarily mean that they get to dodge the bullet. In Python 2, if you read data from a file, you get raw bytes, but if you read data from parsed JSON, you get Unicode strings - because JSON itself is guaranteed to be Unicode. Guess what happens when the byte string you've read from the file, and the Unicode string you've read from a JSON HTTP response, are concatenated?