Python 3.14 garbage collection rigamarole
Posted by eatonphil 5 days ago
Comments
Comment by zzzeek 3 days ago
Comment by picofarad 3 days ago
The solution was to upgrade Python. But I won't, because that was the problem in the first place, here, apparently.
Oddly if I ran the whole thing under memray with a different allocator, no issue. I say oddly but it isn't.
So I guess my matrix server is broken until I rehome it on a new server with a fresh python instead of 3.10.8.
Comment by a_t48 3 days ago
Comment by emil-lp 3 days ago
Reverting the incremental GC in Python 3.14 and 3.15
265 points, 130 comments
Comment by _old_dude_ 3 days ago
So I do not understand why it's a surprise that minimizing the pause time requires more memory. Is it because there is no knob to set either the max pause time or the max memory ?
Comment by p_l 3 days ago
Comment by zelphirkalt 3 days ago
Do I have any misconceptions?
Comment by vlovich123 3 days ago
Figuring out how to measure the size of an object can be tricky of course, but I suspect there’s all sorts of things you could try including figuring out how much memory got deallocated after you gc a cycle and attributing it to where the object got allocated as a heuristic to measure the mean allocation size.
Comment by nomel 3 days ago
I'm sure all the people that have been working on this for years would be interested in your small tweak, that they didn't think of, and would happily accept the PR!
Comment by elfly 2 days ago
Maybe in all those years they could have thought of that.
Comment by favorited 1 day ago
https://discuss.python.org/t/reverting-the-incremental-gc-in...
Comment by vlovich123 3 days ago
a) do work to reduce issues as they come up b) appease the vocal complaints
A takes work, guts, and risk. Option b was chosen with the GC work basically saddled with so much process it’s never going to change. Python has a very storied history of being very committee driven design so the committee did the committee thing.
Comment by scott_w 3 days ago
Tweaking the GC while the system was functionally broken is the worst time to do it. Correct incident response is revert first, figure out how to fix it later.
Comment by vlovich123 3 days ago
Comment by scott_w 2 days ago
On what planet is the currently released version of any software "not a live system?"
Comment by vlovich123 2 days ago
You are responsible for that, not them. And if Python 3.13 is fine for you and you report a performance regression for 3.14, you can still stay on 3.13. And as you say, it was introduced in a new release. What happens when the other side goes and says “3.14.5 regressed on the GC pause times and my p95 web server latencies went up. Please revert”? At least one side can make the case “performance was changed on a major release of Python boundary” while the other is changing the performance on a minor release boundary. It’s an arbitrary decision that speaks to the politics of the organization and less about a well reasoned technical plan.
Comment by scott_w 2 days ago
I really don’t have words. When people bemoan the state of software engineering, your comment here is exactly what they’re talking about.
Comment by vlovich123 2 days ago
As for Windows, I think you need a better example. OSes frequently change their performance profile on certain workloads and use more memory. Terrible example.
Also please cool it with the personal insults. They’re not productive and shows you’re trying to win the argument through force and emotion instead of reason.
Comment by Orygin 2 days ago
Comment by scott_w 2 days ago
You mean software that has to be deployed locally? Like the example I gave?
> you'd know the world of difference
It's actually worse. The longer you take to get a fixed version out there, the more people will install the buggy version. As distribution is more difficult than just merging a Github PR, that buggy version will live longer on live systems. And before you say "but it's on the developer/DevOps/sysadmin to test," I point you to the countless CVEs where this didn't happen.
Knowing this is the situation, it's unconscionable to leave a faulty build on live for longer than necessary, when you can rollback the change with limited risk.
Comment by evilturnip 3 days ago
In fact, I think Guido himself resigned due to the experience he had trying to get a PEP through the committee.
Comment by japhyr 3 days ago
If you're referring to the steering council, that group was created in response to Guido stepping down.
He stepped down partly in response to the changing nature of online discussions around changes to the language. He just didn't want to be at the center of every polarizing discussion anymore. I think he also recognized that the transition needed to happen at some point, and that was as good a time as any.
Comment by watt 3 days ago
Comment by rciorba 3 days ago
Comment by tannhaeuser 3 days ago
My experience with Python is a really bad one for professional work: it's chaotic and slow, and has by far the worst versioning and packaging story of any mainstream language, yet its proponents keep praising it in denial.
I guess Python is an ok target for agentic coding, but my god do look Claude's commit messages pretentious, with code bases quickly heading into absolute unmaintainability. At least it had found gross JS injection vectors in a Django app that really shouldn't have made it through a code review, architecture level as they were, but oh well. A mature Django app is also not a nice dev experience IMO, with tons of implicit behavior all over the place encoded in a mix of magic filenames, database naming conventions, and URL routing quickly descending into regexp hacks.
Comment by NeutralForest 3 days ago
Some people just don't have the experience you do, "its proponent keep praising it in denial", can we have a better level of debate, come on now.
Comment by rurban 3 days ago
The slowest of all dynamic scripting languages. Breaking ABI's and API's left and right all the time. Not able to implement basic performance optims. Their infrastructure (pip) getting worse and worse, getting everyone to install private venv's for every app, leading to missing security updates, because updates just break everything.
People just love trouble.
Comment by notatallshaw 1 day ago
Hi, I'm a pip maintainer, can you please report any issue you think is happening in recent versions of pip: https://github.com/pypa/pip/
I particularly work on performance and stability and think we've been making big strides over the last two years
> getting everyone to install private venv's for every app, leading to missing security updates, because updates just break everything.
venv's stop your OS tooling from breaking, Linux distro maintainers pushed Python packaging to not allow installing into the system packages by default, and they weren't wrong.
All these other problems are solved with proper use of a lock file (which are now standardized, and you can generate and install from them in the latest version of pip), and/or use a project tool (uv, poetry, etc.).
Comment by throwaway81523 2 days ago
Comment by quacker 1 day ago
Reasons: The Python 2->3 transition, asyncio package, async/await function coloring, abysmal package management, the GIL and poor performance, breakage from version to version. I'm ambivalent on type hints. I regret nothing, especially after seeing how the GC and JIT projects have been handled.
Golang addresses all of my problems with Python. Native code, good performance, an exceptional toolchain, a built-in package solution, great concurrency support, and they prioritize compatibility across versions. AI is good at writing Golang (as good as any other language I've tried), and AI benefits a lot from static types.
Comment by nijave 3 days ago
I don't think it's chaotic. I won't deny it's somewhat slow however usually anything performance sensitive gets shoved in a native code extension anyway.
As for packaging, I haven't had any problems with poetry or uv. The only time I ever had issues was with Windows in corporate environments where wheels were unavailable and it was also basically impossible to get the right toolchain installed for native code. However, not being able to install a compiler is not really a Python problem
Claude Code has a setting to change the git template so it doesn't attribute itself or you can also commit manually.
Comment by shakna 3 days ago
Comment by tannhaeuser 3 days ago
3.14 broke GC
I guess these kinds of priorities are exactly why Python is not my favorite programming language and why you have tens of Python versions installed on any machine. Not to talk about the Python 2 -> 3 drama that was also about fetishising syntax and pureness over pragmatism, installed base, and respect for existing code.
Comment by throwaway81523 2 days ago
Comment by shakna 2 days ago
[0] https://discuss.python.org/t/c-api-my-plan-to-clarify-privat...
Comment by throwaway81523 2 days ago
Comment by amelius 3 days ago
Comment by postdoc74 3 days ago
Comment by targafarian 3 days ago
I do a lot of what I need symbolically in SymPy for dynamics analysis. Past that, I can't speak for it. At University I used Mathematica, but I just don't need all it can do at this point, so once again Python has proven to be "good enough." Matlab will be a similar story (e.g., I've never seen a good alternative to Simulink in Python).
But for everything else outside very specific domain tasks? Mathematica and Matlab are terrible for a lot of reasons. So I'll go out of my way to stay within the Python ecosystem, though I'm not afraid to pull out the specialty tools when I just can't make Python do the task near as well and/or nearly as quickly.
Comment by amelius 3 days ago
Comment by amelius 3 days ago
More and more applications need to use ML these days. So Python use will only grow.
Comment by jeremycarter 2 days ago
Comment by zahlman 3 days ago
Comment by carra 3 days ago
Comment by ameliaquining 2 days ago
Comment by vaultwright 2 days ago
Comment by sspoisk 3 days ago
Comment by ryanshrott 3 days ago
Comment by irishcoffee 3 days ago
Comment by zhanbing 3 days ago
Comment by functionmouse 5 days ago
If they didn't have very good objective reasons the new GC is better, they never should have shipped it. If they do, they should not have reverted the change.
Comment by ameliaquining 3 days ago
Comment by petre 3 days ago
Comment by moron4hire 3 days ago
I felt like the tooling in Racket, CLisp, and Java were similarly pragmatic and not either religiously devoted to some concept of "backwards compatibility" that I seriously doubt most people actually need, or "ease of use" that actually proves itself to be easy when you consider the not-happy-path of the beginner tutorials. Racket, I didn't continue just because the library ecosystem isn't mature enough to keep up with the latest in databases and other 3rd party services. Java I quit largely because of Oracle and some 2010s problems with stagnation. CLisp mostly because it was too hard to socialize. But never because I thought the core language and tooling were holding me back.
Comment by graemep 3 days ago
Even if you dislike the direction Python is going in, a lot of what attracted people to Python in the first place is still there. The readability, the large standard library, the huge ecosystem. There are libraries and frameworks for everything: numerical stuff, web development, GUIs etc. Its actually a nice language in itself, just going in the wrong direction now.
If you look at it historically it was really good comparatively. If you compare it to the alternatives available 20 years ago it looks pretty good.
Comment by petre 3 days ago
Because of the libraries, not necessarily the language, which is also quite straightforward. For example we found a niche library that speaks the ISO-TP protocol in Python, which allows us to communicate with vehicle ECUs. That's why people also use C++, even tough I quite doubt it's because they like the language. Add to that that it's also heavily used in embedded programming. Yes, you could call a C/C++ library from another language, depending how well the language can do that.
I prefer Ruby, but Python probably has just about everything one would need. It's also great for data processing. We hardly have anything better than pandas, polars, numpy, scipy in other languages and that:s without even mentioning ML tooling.
Comment by hankbond 3 days ago
Packaging can be irritating although uv takes the sting out a bit.
You are right that outside of verbosity, once you get used to the syntax of a language, the value of one over the other kind of fades.
Comment by Kwpolska 3 days ago
uv proves the OP’s point. Why couldn’t the core team and the core-adjacent PyPA make a tool as liked as uv, and why is the Python package manager uv written in Rust and not Python?
Comment by necovek 3 days ago
Comment by CamouflagedKiwi 3 days ago
Comment by zahlman 3 days ago
Incredibly large backward-compatibility burdens [0], internal politics [1] and general institutional dysfunction (no footnote; if you're familiar then you need no explanation, and if you aren't then the less said the better). Nothing to do with Python as a language. Most of the important pieces to get uv-like performance are algorithmic choices, and most of the rest are available as built-in C code in the reference implementation [2].
(Edit: wait, I recognize your username. You should definitely know these sorts of things.)
> why is the Python package manager uv written in Rust and not Python?
Because that's the language that Astral devs like, and because installing Python itself is considered in scope for uv so there would be an intractable bootstrapping issue.
[0]: In particular, the entire model of `setup.py` defining metadata is certifiably insane, especially when you consider the projects that expect to feed that code to Setuptools at build time in order to figure out what version of Setuptools is needed at build time. But this legacy approach is seen as something that absolutely must be guaranteed to work for well beyond even now; even attempts to remove long-deprecated, minor aspects of that functionality end up breaking major projects, including ones that didn't even require a build step in the first place [3].
[1]: Most obviously, GvR not wanting to have anything to do with it when initially approached by the SciPy people in IIRC 2011, leading to the creation of Conda). But a lot of other things, too. The backwards-compatibility issues synergize with this; consider for example the architectural dumpster fire of Setuptools, and the timeline of distutils removal from the standard library.
[2]: See e.g. my analysis in https://zahlman.github.io/posts/oxidation/ .
[3]: See e.g. my LWN article https://lwn.net/Articles/1020576/ .
Comment by moron4hire 3 days ago
Comment by Yossarrian22 3 days ago
Comment by zahlman 2 days ago
Comment by throwaway81523 2 days ago
https://news.ycombinator.com/item?id=7802575
From the link: "You know why I'm not running python 3? Because it doesn't solve a single problem I have. It doesn't solve anyone's problems. It solves imaginary problems, while creating real problems."
Comment by pjmlp 3 days ago
They are as standard as arguing about Ant, Maven, Gradle in Java, npm, pnpm, yarn in node, and so on.
However I fully agree with the gist of your comment, basically Python is the new BASIC.
However at least BASIC was compiled, with exception of the 8 bit home micros.
Comment by Lutger 2 days ago
Take list comprehensions for example. It is mostly syntax: you can do virtually all list comprehensions with just a map and filter function. But the way that it is integrated and presents the code, makes is vastly easier to follow for most developers, which tilts the balancer in favor of doing away with loops and mutable state. Is it syntax that made them do so? Yes, maybe. But its the actual semantics that provide the value.
Comment by zahlman 3 days ago
Syntax really does matter more than you give it credit for. Were that not the case, I'd expect one Lisp or Scheme dialect or other to take Python's place. Outside of that counterfactual, Python's competition was stuff like Ruby, and it turned out that network effects were also pretty important.
Comment by throwaway81523 2 days ago
Comment by SJC_Hacker 3 days ago
Comment by Kwpolska 3 days ago
Comment by necovek 3 days ago
People mostly defer to requests because they do not track language development closely and because we are creatures of habit.
I try to avoid non-stdlib packages when stdlib will do a good job, but I received negative feedback from people who aren't aware of the updates and couldn't foresee supply-chain attacks.
Comment by zahlman 3 days ago
Comment by necovek 3 days ago
Urllib2 is now also gone and mostly replaced with urllib.request.
It should cover 99% of the use-cases one would use requests for — I am not sure how and why it matters that it is a subpackage and not a top-level package?
This is just a natural evolution of a widely used language where you have to be careful with backwards compatibility.
Comment by graemep 3 days ago
A Python codebase might well use requests, but it will almost always also heavily use the standard library.
Comment by BoingBoomTschak 3 days ago
Comment by zahlman 3 days ago
Historically, the standard library made sense. And we're talking about a history that stretches back to before Internet connections were ubiquitous, to say nothing of connection speed.
Now the standard library is full of things that they refuse to remove because it would supposedly be too disruptive, but which they would never think of adding today if they weren't already there.
Comment by hmry 3 days ago