3 ms·
The problem is, they are calling it a mistake but they were very well informed of the consequences of doing that they did. Everybody said "just fix integer div
by dekhn 5y ago
The problem is, they are calling it a mistake but they were very well informed of the consequences of doing that they did. Everybody said "just fix integer division and print, finish the migration then start adding new features", and they went ahead and totally ignored that.
- sophacles 5y agoWhenever I work on a project that gathers interest in multiple places I get input like: * If you do X you'll fail * If you don't do X you'll fail * X is neat but don't worry about it til later. I imagine that the people in charge of python, a wildly popular programming language (at the time, and still), got all sorts of input, much of which conflicted. They chose a path and it was a bad choice, a mistake. This is clear in retrospect 13 years later, but at pycon in 2008 (a few months before python 3 officially released) the viewpoint was more mixed - a lot of people thought it was a good path and a lot of people thought it was terrible and others still thought the transition plan was annoying but would be cleared up pretty quick.
- Blikkentrekker 5y agoIt's not so much the issue that it is clear that it was a bad decision. — they admit it, owe up to it, and I do not blame them for making the mistake and admitting it was unfortunate and that they learned their lessons. What drives me to ire to no end are the many people that defend it on message boards with “Just upgrade; you had ten years.”, clearly not realizing the risks and money involved in such an endeavor. It's as though the government suddenly start putting something in the water that improves it's health benefits, but will erode contemporary plumping pipes away in ten years and people say. “Just break down your walls and replace your plumbing; you have ten years.”. — it is quite expensive, and risks that my house fall over.
- nindalf 5y agoThis is a reasonable take, but think about this from the perspective of engineers who've never made any mistakes in their lives. It's hard for them to fathom how anyone else can make a mistake like the Python devs did. The person you're answering clearly had the foresight to know what was the right thing to do, why can't everyone?
- tachyonbeam 5y agoAs an outsider: what was the problem with integer division?
- AnIdiotOnTheNet 5y agoUnless you come from a programming background where floor behavior is expected for integers, it was strange. In Python 2: 20 / 15 = 1 In Python 3: 20 / 15 = 1.3333333333333333 To get the old behavior a new operator was added "//"
- guenthert 5y ago> Unless you come from a programming background where floor behavior is expected for integers, it was strange. In all fairness, the C/C++ and Java communities were and are quite substantial. Of course the rest of us ought to expect 4/3 as the result of 20/15 ;-)
- pansa2 5y agoPython’s separation between ints and floats is quite weak, so it didn’t make sense for `3 / 2` to give a different result from `3.0 / 2` (1 and 1.5 respectively). Python 3 changed the division operator to return 1.5 in both cases.
- LeifCarrotson 5y agoPython isn't strongly typed. You got an integer floor operation with -3 / 2 = -2, but -3.2 / 2 = -1.6. This led to errors when floats were expected but integers were possible among your inputs. In Python 3, it always gives a floating-point result. You can use a floor division operator if you want to round everything (including integers) towards negative infinity. See https://www.python.org/dev/peps/pep-0238/ https://www.python.org/dev/peps/pep-0238/ for details.
- leephillips 5y agoPython is strongly typed, and your examples show the strong (dynamic) type system in action. An example of a language that is not strongly typed would be Javascript, where you can do 1 + "1". In Python, that gets you a typeerror, because Python is strongly typed.
- at_a_remove 5y agoI started reading about Python long before I began programming in it (partially due to a deeply terrible book on the topic I purchased). I ran across the integer division bit and stopped cold. "That," I remember thinking, "is a language feature they will change."
- leephillips 5y agoIs that because you didn’t have experience with other languages? Because integer division in python2 worked in the way I had come to expect from Fortran, etc.
- at_a_remove 5y agoNo, precisely the opposite: it is because I have tons of experience with many other languages. I get why some people think a default integer division is a good idea. I do. Having said that, it was clear that Python was aiming itself at being a kind of glue language wherein various functions were obvious, and integer division is not obvious to someone picking up programming for the first time. If I walk up to someone and ask "What's three divided by two?" I would expect more "One and a half" answers than "Two goes into three just the one time."
- chrismorgan 5y agoEh, the Unicode situation was irredeemably awful in Python 2 because of the era it was of. Fixing that could never have fitted into what you describe. It had to be a significant breaking change, and even if Python 3’s string handling isn’t perfect (its strings are sequences of Unicode code points, not Unicode scalar values, so they can be ill-formed which was madness to allow; I say they should have gone all in on UTF-8 instead, which trades away some sorely misleading, tempting but practically quite useless functionality in favour of performance and memory usage), it’s vastly better than the situation in Python 2, where you pretty much just couldn’t be sure of anything—on many common configurations, you couldn’t even reliably output Unicode, and might not be able to at all without setting the PYTHONIOENCODING=utf-8 environment variable before starting Python, if my memory serves me correctly (I am glad to say that I haven’t had to deal with python2 for five years now).
- tyingq 5y agoTrue, though that's one of the things that 2to3 couldn't deal with, because it's not possible to do so automatically. It can't have had any idea what was supposed to remain a string, and what was supposed to become bytes.
- tobiasSoftware 5y agoMy problem was that there were other unspecified things that 2to3 couldn't deal with. Imagine the world where the upgrade guide was to run 2to3 and then it had explanations of how to address the remaining string issues. Instead, I found the attitude of "run 2to3, it'll probably work but if it doesn't, then you'll have to figure it out yourself."
- tobiasSoftware 5y agoIn my opinion, the issue was that they used this feature as an excuse to have other breaking features that weren't really needed. I think besides the string upgrade, every other breaking feature should have worked with 2 to 3. Then they could have had a clear upgrade guide that is to run 2 to 3, then clear explanations on how to fix all the remaining string issues. Instead, I have no clue what 2 to 3 fixes and what it doesn't, leading to "2 to 3 will probably work, but if it doesn't, then you'll just have to figure it out yourself." That's unacceptable, and as a result caused many libraries to take a long time to upgrade. Personally, I had to spend 10 YEARS to wait to upgrade to Python 3 due to the wxPython library that all of my projects used that took that long to upgrade to Python 3.