News for hackers. Stuff that matters.
Re:Python adopts a 12-month release cycle by Cyph0n on Friday November 01, 2019 @12:45PM (#21420832)
Are you referring to the Python 2 -> 3 fiasco? If so, I think that the Python language committee will never make such a mistake again. They've seen first-hand how difficult it is to get the ecosystem to move forward after a breaking change like that.

But within Python 3, I think the deprecation system is decent. As far as I know, it really only occurs with "uncommon" APIs, so the vast majority of code will continue to work as expected on later Python 3 versions.

Re:Python adopts a 12-month release cycle by kstrauser on Friday November 01, 2019 @01:00PM (#21421045)
I don't think it was a mistake. There were some intractably difficult, "rip-the-band-aid-off" types of changes that had to happen at some point. The PSF decided that 3.0 was the right time to make those one-time changes so that future migrations could be as small as possible.
Re:Python adopts a 12-month release cycle by excessive on Friday November 01, 2019 @01:41PM (#21421625)
> There were some intractably difficult, "rip-the-band-aid-off" types of changes that had to happen at some point.

I suspect you're referring to Unicode here. In that case, I think they could've just added a flag to Python 2's str type to indicate "is UTF-8" and deprecated the old unicode object. Then add some functions to extract code points or grapheme clusters or whatever else you need from the old school str object.

I might be in the minority, but I really like that Python 2's str could hold arbitrary binary data, of which UTF-8 is just one possibility. It had good interop with C, which I think is fundamental to a glue language like Python. I'd rather have fewer string types instead of more (one of my complaints about Rust too).

If you meant the print function, there were other ways to solve that too. The simplest might be to create a new name for the function and deprecate the print statement. So old code uses the statement "print 123" while new code is encouraged to call the function "echo(123)" or "ouput(123)". Bikeshed the actual name...

Note when I say "deprecate", I mean provide a timeline over several releases where it continues to work. Then issue deprecation warnings which can be silenced.

All of the newer features in Python 3 (@ operator, async/await, type annotations, etc...) could've been added in a mostly backwards compatible way. (Note: adding async wasn't really backwards compatible even in Python 3).

Anyways, hindsight is 20/20, but I really do think the path for Python 3 was a poor choice in comparison to other options.

Re:Python adopts a 12-month release cycle by kevin_thibedeau on Friday November 01, 2019 @01:54PM (#21421800)
Your proposal only works well for US ASCII users. What if I want to manage multiple ISO-8859 encodings in conjunction with 7-bit ASCII? Maybe I also have some EUC-JP multi-byte text to deal with. It becomes an intractable mess without explicit encoding management. Someone will absolutely end up misinterpreting encoded text as bytes and cause all manner of compatibility and security issues. Having a Unicode string type forces this to be dealt with even if it is inconvenient when taking in data from outside the Python environment.
Re:Python adopts a 12-month release cycle by excessive on Friday November 01, 2019 @02:19PM (#21422085)
> Your proposal only works well for US ASCII users.

No, and I explicitly mentioned UTF-8. My suggestion is that str holds arbitrary immutable binary data and that you have a method which can interrogate whether that binary data is valid UTF-8.

Yes, real world text is messy and there are lots of encodings, compression schemes, and exceptions (UTF-8 with byte order marks, overlong encodings, or surrogate pairs, as examples). If your main task is converting text between outdated or broken encodings, I don't have any problem saying you need a separate library and shouldn't burden the rest of the user base. Despite it's flaws, the majority of the world has settled on Unicode with a UTF-8 encoding.

"Special cases aren't special enough to break the rules."

Re:Python adopts a 12-month release cycle by slavik81 on Friday November 01, 2019 @07:12PM (#21424672)
> I really like that Python 2's str could hold arbitrary binary data

Python 3's str can also hold arbitrary binary data. That ability was introduced in PEP 383.

Re:Python adopts a 12-month release cycle by excessive on Saturday November 02, 2019 @03:06AM (#21426298)
Thank you for telling me about this - I didn't know they did that...

My first thought as I started reading the PEP was, "Why did they bother adding the 'bytes' type if 'str' is just going to be able to hold everything anyways?"

After looking at more of it though, it seems like they're storing the binary octets as code points in one of several internal Unicode representations. Moreover, they're abusing (reusing?) the range of code points reserved for 16 bit surrogate pairs, but only using the low half of the pair. This is all clever in the bad way.

This seems like a real lack of taste to me, and I doubt the Guido from 1991 would've found it acceptable to have 'str', 'bytes', and 'bytearray' the way they are. (Let's ignore 'buffer' became 'memoryview' for now...) It used to be a simple and elegant language.

Re:Python adopts a 12-month release cycle by kec on Friday November 01, 2019 @01:25PM (#21421394)
Aside from Unicode strings, what changes actually required breaking backwards compatibility.

For that matter, why did the switch to unicode strings require breaking backwards compatibility? I don't understand why we couldn't just move to assuming all strings are utf8 unless specified otherwise. Keep [] byte oriented, add a .at() method to index by code point.

Re:Python adopts a 12-month release cycle by takeda on Friday November 01, 2019 @01:52PM (#21421776)
The reason for it were bad decisions made in older version of python. The problems were:

- conflating text with bytes, python had no way to tell whether given string is a text or bytes, because in 2.7 was the same thing.

- introducing unicode as an unicode type, this essentially made the problem worse because in addition to mixing text with strings, they added extra type to represent text, which was optional and some people used unicode some didn't.

- a cherry on top was implicit conversion, so if you passed unicode type where str was expected python implicitly converted it, and vice versa

This basically resulted in people writing a broken code in python 2, code that worked fine with us-ascii, but randomly blew up if there ware some non standard characters processed.

In python 3 instead applying another fix, they decided to do it correctly from the start. So str (Guido actually regretted he didn't called it text) is representing text and bytes are representing, well bytes. Python 3 also does not do implicit conversion as well.

I actually think they could perhaps help with migration, by adding to 2.7 one more import to __futures__ that disables implicit conversion and then treat bytes type as a distinctly different type than str. That could help people fix their code in 2.7 before migrating it, but anyway it's already too late to do it, also there is a hack that you could disable implicit conversion in python 2, but it showed that stdlib also relied on it heavily, so fixing that maybe was not worth it.

Re:Python adopts a 12-month release cycle by cft on Friday November 01, 2019 @01:07PM (#21421145)
Then why didn't they remove GIL? Given the end of Moore's law and Python's performance, this alone would have justified the discontinuity.
Re:Python adopts a 12-month release cycle by dashwav on Friday November 01, 2019 @01:19PM (#21421324)
Because the GIL is only a problem in specific sets of problems that the majority of python users won't run into. With the addition of asyncio etc, the negative of GIL is usually pretty restricted to CPU-heavy, blocking services which the core team decided was a very small subset of users. So removing the GIL would require an extremely heavy rewrite of the way python works at a fundamental basis, and it would break a lot of the "promises" that python affords in regards to memory management and safety.

As an aside, there is currently a PEP that will allow for better concurrency __without__ removing the GIL, [PEP554](https://www.python.org/dev/peps/pep-0554/)

and a larger project overall for multi-core support, which is (hopefully) being included in 3.9 [Multi-core](https://github.com/ericsnowcurrently/multi-core-python)

Re:Python adopts a 12-month release cycle by kstrauser on Friday November 01, 2019 @01:15PM (#21421262)
There've been various attempts at this over the years, but it's really orthogonal to changes to the language itself.

Also, check out the SharedMemory objects[1] in 3.8. For my own use cases, this goes a long way toward making me no longer care about the GIL. I'd rather work on multiprocessing code than multithreaded code any time, and if you can easily share objects across processes, then the GIL isn't relevant to anything I'm working on.

[1] https://docs.python.org/3/library/multiprocessing.shared_mem...

Re:Python adopts a 12-month release cycle by dickeytk on Friday November 01, 2019 @01:15PM (#21421267)
I would argue the GIL is a feature put in place to make it easier to write parallel code.

If you want to do this in a more performant way you should be looking at a different language.

People talk about the GIL as if it’s just some drawback that could be removed and everything would be faster. There is a very good reason why it’s there.

Re:Python adopts a 12-month release cycle by masklinn on Friday November 01, 2019 @01:32PM (#21421480)
> I would argue the GIL is a feature put in place to make it easier to write parallel code.

It doesn't do that though. The GIL protects interpreter internals. It doesn't make Python code thread-safe, although it does make various operations atomic:

* native calls (which doesn't release the GIL) * individual bytecode instructions (which don't call into more python code)

The latter can make it seem like it magically protects your code, but even a simple method call is at least 3 instructions (LOAD_FAST, LOAD_METHOD and CALL_METHOD). Each instruction is atomic and the method call will be if it's a native call (e.g. dict.get) but that's it, the entire call itself is not atomic and you could thread-switch between LOAD_FAST and LOAD_METHOD, or LOAD_METHOD and CALL_METHOD.

Re:Python adopts a 12-month release cycle by dickeytk on Friday November 01, 2019 @01:38PM (#21421582)
You just explained a bunch of implementation details but at the end of the day my point remains: having the GIL makes it easier to write parallel code. I didn't say it magically makes everything threadsafe.
Re:Python adopts a 12-month release cycle by masklinn on Sunday November 03, 2019 @06:53AM (#21433353)
> having the GIL makes it easier to write parallel code.

It does not. What it does is create a bigger trap, because the code looks to be working in more testing situations, and will be more difficult to debug when it starts failing.

Re:Python adopts a 12-month release cycle by laurencerowe on Friday November 01, 2019 @02:26PM (#21422167)
Assuming you mean concurrent rather than parallel as the GIL prevents you from running Python code in parallel. How does the GIL make things easier compared to the finer grained locking found in Jython which allows parallel execution of Python code in threads?

Threads may still be switched between instructions every sys.setswitchinterval milliseconds so every instruction boundary is still a potential thread switch point, leading to all the issues described by Glyph in his Unyielding essay: https://glyph.twistedmatrix.com/2014/02/unyielding.html

Re:Python adopts a 12-month release cycle by pavanky on Friday November 01, 2019 @01:33PM (#21421518)
Isnt the GIL part of the implementation rather than the language?
Re:Python adopts a 12-month release cycle by dickeytk on Friday November 01, 2019 @01:42PM (#21421640)
In the same exact way the garbage collector is. You never touch it but the fact it's there makes it easier to write code.
Re:Python adopts a 12-month release cycle by fiedzia on Friday November 01, 2019 @01:15PM (#21421261)
Because GIL is useful, preventing you from shooting yourself terribly in the foot among other benefits. Languages with better concurrency support (main reason for removing GIL) were designed from scratch for that purpose. You can't remove GIL and keep Python being Python everyone knows. And if you don't mind using another language, there are many choices.
Re:Python adopts a 12-month release cycle by laurencerowe on Friday November 01, 2019 @02:34PM (#21422255)
I believe Jython offers the same level of protection against shooting yourself in the foot as CPython, yet it allows allows for parallel execution by relying on finer grained locking. The concurrency issues with threads are still present in CPython with the GIL as the interpreter may switch threads between any instruction.
Re:Python adopts a 12-month release cycle by the_why_of_y on Saturday November 02, 2019 @04:41AM (#21426563)
In addition to the points other people raised, "simply" removing the GIL by changing the current reference-counting GC to do atomic reference updates will also substantially reduce single threaded performance; there was a PyCon talk about that.

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

See also Swift for another language whose implementation has performance issues caused by ubiquitous atomic reference counting.

Re:Python adopts a 12-month release cycle by Ralfp on Friday November 01, 2019 @01:21PM (#21421347)
Removing GIL will break ecosystem in worse way than Python 2->3 ever did, as both interpreter and compiled libraries rely on it for thread safety.

There are other paths for improving performance that Python is embrancing: asyncio provides considerable performance gains to IO bound apps, and memory-sharing between processes allows for relatively cheap sidestep for those who find threads too slow for their use-case.

Re:Python adopts a 12-month release cycle by mikepurvis on Friday November 01, 2019 @12:53PM (#21420956)
I think there's also an effect where some of us have gotten used to Python 2.7.x being utterly predictable and unchanging for like, the decade since it came out.

It's not Python's fault, but for example I was trying to get something running on Ubuntu 16.04 (Python 3.5) where the primary developer of it is running Ubuntu 18.04 (Python 3.6), and it seems like 3.5's version of the asyncio module has a bunch of bugs that make the tool in question basically unusable.

I know the usual advice— install newer Python from deadsnakes, use a virtualenv, etc. None of this stuff is the end of the world, but it can be jarring if you're only now getting off the Python 2.7 train and used to everything just working everywhere.

Re:Python adopts a 12-month release cycle by kstrauser on Friday November 01, 2019 @01:17PM (#21421298)
That's not really fair, though. If the developer were writing it on 2.7 and you were running it on 2.6, I wouldn't hold that against Python 2.
Re:Python adopts a 12-month release cycle by mikepurvis on Friday November 01, 2019 @01:49PM (#21421716)
Oh I completely acknowledge that. This is less about Python and more "fast moving platform" vs "slow moving platform".
Re:Python adopts a 12-month release cycle by takeda on Friday November 01, 2019 @03:05PM (#21422574)
well asyncio was introduced in 3.5 though, it just happened that initial version was buggy and you should assume asyncio is available since 3.6 (or actually 3.5.3+)
Re:Python adopts a 12-month release cycle by pletnes on Friday November 01, 2019 @01:48PM (#21421700)
How was it a fiasco? The old version was supported for free for what, a decade? Usage of python is skyrocketing. I don’t know anyone who honestly prefer 2 over 3. The number of python packages released in one year now is probably higher than that of all years combined up to the release of python 3.

The process was not perfect, but in my book it’s a success.

Re:Python adopts a 12-month release cycle by 3JPLW on Friday November 01, 2019 @01:50PM (#21421728)
It was a fiasco because it wasn't possible (until much later) to support both Python 2 and Python 3 in the same code base. This made for a gridlock between dependencies and users.
Re:Python adopts a 12-month release cycle by aroberge on Friday November 01, 2019 @02:50PM (#21422418)
This is a misconception that has likely been compounded by the initial advice (by core Python folks, who eventually reverted their stance) on not doing this. For example, see this blog post https://aroberge.blogspot.com/2009/08/crunchy-10-released.ht... from 2009 for a non-trivial program that supported Python 2.4, 2.5, 2.6 and 3.1. It was a bit of a pain as it dealt with lots of unicode/strings, but it was doable. It became easier to support both Python 2 and Python 3 later on, especially once Python 3.2 was released.
Re:Python adopts a 12-month release cycle by 3JPLW on Friday November 01, 2019 @04:32PM (#21423401)
Ok, sorry, replace "not possible" with "very difficult and not recommended."

I don't see how that changes what I wrote in a very meaningful way.

Re:Python adopts a 12-month release cycle by AlexeyBrin on Friday November 01, 2019 @12:50PM (#21420907)
> But within Python 3, I think the deprecation system is decent. As far as I know, it really only occurs with "uncommon" APIs, so the vast majority of code will continue to work as expected on later Python 3 versions.

The problem is that every new Python version seems to break something. Python 3.8 was released almost two weeks ago, and some popular libraries still don't work with it, e. g. SciPy, Matplotlib, OpenCV, PyQt, PySide2 and probably a bunch of other libraries that depend on the above.

Re:Python adopts a 12-month release cycle by jacquesm on Friday November 01, 2019 @01:20PM (#21421334)
Which is just about everything outside of Keras/Tensorflow that I use. Highly frustrating. Languages should be designed with backwards compatibility in mind right from day #1. Porting code isn't free.
Re:Python adopts a 12-month release cycle by willis936 on Friday November 01, 2019 @12:51PM (#21420924)
Mostly, yes, as I’m responsible for a data acquisition system written 10 years ago. “Just” getting to python 3 is a massive effort which would first require getting to 2.7 from 2.5, which itself would be a time consuming task. I’m starting to think the best solution would be to just stay on python 2.5. Updates to software should not be the implementer’s tormentor.
Re:Python adopts a 12-month release cycle by acdha on Friday November 01, 2019 @02:26PM (#21422165)
If you still haven't upgraded from a version released 13 years ago to one released 9 years ago, what difference does a slightly faster release tempo make? If it's that much work, something else has gone wrong in the software development process and all the Python upgrades are doing is making that failure harder to ignore.
Re:Python adopts a 12-month release cycle by 3JPLW on Friday November 01, 2019 @12:54PM (#21420966)
Then this is an unfair critique of this new release process. If you had issues with breaking changes between minor 3.x versions, then I'd fully understand.
Re:Python adopts a 12-month release cycle by willis936 on Friday November 01, 2019 @12:57PM (#21421006)
Are complaints about things breaking between 2.x versions somehow invalid? It’s the same steering group that has made a series of breaking changes. Even people on branches of this thread claim there are breaking changes in 3.7 > 3.8. I’m not sure I would willingly use python for any new project unless necessary, putting it into the same bin as national instruments.
Re:Python adopts a 12-month release cycle by vcxy on Friday November 01, 2019 @01:20PM (#21421339)
It's a valid complaint on it's own, sure. But it kind of looks like you're complaining that they're going from an ~18 month cycle to a scheduled 12 month cycle. It's not really valid as a complain for this particular change. You're talking about a decade. 18 months vs 12 months seems inconsequential for you.
Re:Python adopts a 12-month release cycle by willis936 on Friday November 01, 2019 @01:39PM (#21421604)
I'm complaining about the ethos of the python maintainers. I don't see how putting out updates more rapidly will do anything to my complaints other than make future me dislike using python even more. At first I thought they missed a beat but now I think they're playing free jazz.
Re:Python adopts a 12-month release cycle by 3JPLW on Friday November 01, 2019 @01:49PM (#21421709)
The 3.x releases _are nothing like_ the 3.0 release. You have a valid complaint about the 3.0 release, which was 11 years ago. If you've not tried updating from 3.x to 3.y — which is a very different process — then you have no stake in this change.
Re:Python adopts a 12-month release cycle by icegreentea2 on Friday November 01, 2019 @02:24PM (#21422139)
It's your call to make. If your system doesn't have some sort of 'security' risk to it, then all the reasons you have to upgrade are purely internal cost-benefit analysis.

Code is a tool, treat it like any other. Just be aware of possible accumulating deferred costs. I don't know exactly what field your in, but just imagine any other piece of equipment or component going EOL, and the manufacturer only providing semi-drop in replacements. Or even if they are advertised as "drop in", you know that half the time they aren't, and something derpy happens on integration.

Re:Python adopts a 12-month release cycle by willis936 on Friday November 01, 2019 @05:24PM (#21423852)
The system is not firewalled from the internet. There are tools that need internet based licenses. There are organization firewalls, but there is always a risk involved with having unpatched platforms. I have to weigh that risk against the cost of porting. Both are difficult to gauge.
Re:Python adopts a 12-month release cycle by icegreentea2 on Friday November 01, 2019 @05:50PM (#21424066)
How are the Python 2.5 components being invoked? Are they python processes that are constantly running? Or are they jobs spun up by other processes?
Re:Python adopts a 12-month release cycle by willis936 on Saturday November 02, 2019 @01:42AM (#21426095)
Oh they’re always running and on dozens of machines.