TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Free-threaded CPython is ready to experiment with

532 pointsby ngoldbaum10 months ago

22 comments

eigenvalue10 months ago
Really excited for this. Once some more time goes by and the most important python libraries update to support no GIL, there is just a tremendous amount of performance that can be automatically unlocked with almost no incremental effort for so many organizations and projects. It's also a good opportunity for new and more actively maintained projects to take market share from older and more established libraries if the older libraries don't take making these changes seriously and finish them in a timely manner. It's going to be amazing to saturate all the cores on a big machine using simple threads instead of dealing with the massive overhead and complexity and bugs of using something like multiprocessing.
评论 #40952245 未加载
评论 #40949637 未加载
评论 #40952465 未加载
评论 #40955303 未加载
评论 #40951822 未加载
评论 #40958089 未加载
评论 #40951583 未加载
评论 #40954354 未加载
评论 #40958085 未加载
评论 #40950539 未加载
simonw10 months ago
I got this working on macOS and wrote up some notes on the installation process and a short script I wrote to demonstrate how it differs from non-free-threaded Python: <a href="https:&#x2F;&#x2F;til.simonwillison.net&#x2F;python&#x2F;trying-free-threaded-python" rel="nofollow">https:&#x2F;&#x2F;til.simonwillison.net&#x2F;python&#x2F;trying-free-threaded-py...</a>
评论 #40951886 未加载
nine_k10 months ago
Python 3 progress so far:<p><pre><code> [x] Async. [x] Optional static typing. [x] Threading. [ ] JIT. [ ] Efficient dependency management.</code></pre>
评论 #40949416 未加载
评论 #40951283 未加载
评论 #40949736 未加载
评论 #40949506 未加载
评论 #40951733 未加载
评论 #40949718 未加载
评论 #40949547 未加载
评论 #40949901 未加载
vegabook10 months ago
Clearly the Python 2 to 3 war was so traumatising (and so badly handled) that the core Python team is too scared to do the obvious thing, and call this Python 4.<p>This is a big fundamental and (in many cases breaking) change, even if it&#x27;s &quot;optional&quot;.
评论 #40953282 未加载
Sparkyte10 months ago
My body is ready. I love python because the ease of writing and logic. Hopefully the more complicated free-threaded approach is comprehensive enough to write it like we traditionally write python. Not saying it is or isn&#x27;t I just haven&#x27;t dived enough into python multithreading because it is hard to put those demons back once you pull them out.
评论 #40949681 未加载
评论 #40949860 未加载
评论 #40949656 未加载
mihaic10 months ago
Does anyone know if there is more serious single threaded performance degradation (more than a few percent for instance)? I couldn&#x27;t find any benchmarks, just some generic reassurance that everything is fine.
评论 #40949628 未加载
评论 #40949644 未加载
评论 #40951740 未加载
discreteevent10 months ago
I remember back around 2007 all the anxious blog posts about the free lunch (Moore&#x27;s law) being over. Parallelism was mandatory now. We were going to need exotic solutions like software transactional memory to get out of the crisis (and we could certainly forget about object orientation).<p>Meanwhile what takes the crown? - Single threaded python.<p>(Well, ok Rust looks like it&#x27;s taking first place where you really need the speed and it does help parallelism without requiring absolute purity)
评论 #40951381 未加载
farhanhubble10 months ago
It remains to be seen how many subtle bugs are now introduced by programmers who have never dealt with real multithreading.
jmward0110 months ago
I know, I know, &#x27;not every story needs to be about ML&#x27; but.... I can only imagine how unlocking the GIL will change the nature of ML training and inference. There is so much waste and complexity in passing memory around and coordinating processes. I know that libraries have made it (somewhat) easier and more efficient but I can&#x27;t wait to see what can be done with things like pytorch when optimized for this.
评论 #40950760 未加载
评论 #40951881 未加载
westurner10 months ago
Will there be an effort to encourage devs to add support for free-threaded Python like for Python 3 [1] and for Wheels [2]?<p>Is there a cibuildwheel &#x2F; CI check for free-threaded Python support?<p>Is there already a reason not to have Platform compatibility tags for free-threaded cpython support? <a href="https:&#x2F;&#x2F;packaging.python.org&#x2F;en&#x2F;latest&#x2F;specifications&#x2F;platform-compatibility-tags&#x2F;" rel="nofollow">https:&#x2F;&#x2F;packaging.python.org&#x2F;en&#x2F;latest&#x2F;specifications&#x2F;platfo...</a><p>Is there a hame - a hashtaggable name - for this feature to help devs find resources to help add support?<p>Can an LLM almost port in support for free-threading in Python, and how should we expect the tests to be insufficient?<p>&quot;Porting Extension Modules to Support Free-Threading&quot; <a href="https:&#x2F;&#x2F;py-free-threading.github.io&#x2F;porting&#x2F;" rel="nofollow">https:&#x2F;&#x2F;py-free-threading.github.io&#x2F;porting&#x2F;</a><p>[1] &quot;Python 3 &quot;Wall of Shame&quot; Becomes &quot;Wall of Superpowers&quot; Today&quot; <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=4907755">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=4907755</a><p>[2] <a href="https:&#x2F;&#x2F;pythonwheels.com&#x2F;" rel="nofollow">https:&#x2F;&#x2F;pythonwheels.com&#x2F;</a><p>(Edit)<p>Compatibility status tracking: <a href="https:&#x2F;&#x2F;py-free-threading.github.io&#x2F;tracking&#x2F;" rel="nofollow">https:&#x2F;&#x2F;py-free-threading.github.io&#x2F;tracking&#x2F;</a>
评论 #40964200 未加载
评论 #40964136 未加载
elijahbenizzy10 months ago
I&#x27;m really curious to see how this will work with async. There&#x27;s a natural barrier (I&#x2F;O versus CPU-bound code), which isn&#x27;t always a perfect distinction.<p>I&#x27;d love to see a more fluid model between the two -- E.G. if I&#x27;m doing a &quot;gather&quot; on CPU-bound coroutines, I&#x27;m curious if there&#x27;s something that can be smart enough to JIT between async and multithreaded implementations.<p>&quot;Oh, the first few tasks were entirely CPU-bound? Cool, let&#x27;s launch another thread. Oh, the first few threads were I&#x2F;O-bound? Cool, let&#x27;s use in-thread coroutines&quot;.<p>Probably not feasible for a myriad of reasons, but even a more fluid programming model could be really cool (similar interfaces with a quick swap between?).
评论 #40950525 未加载
grandimam10 months ago
How is the no-gil performance compared to other languages like - javascript (nodejs), go, rust, and even java? If it&#x27;s bearable then I believe there is enormous value that could be generated instead of spending time porting to other languages.
评论 #40952683 未加载
评论 #40985757 未加载
VagabundoP10 months ago
Highly recommend the core.py podcast if you&#x27;re interested in the background, there are a few episodes that focus on the GILectomy:<p>-Episode 2: Removing the GIL[1]<p>-Episode 12: A Legit Episode[2]<p>[1]<a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=jHOtyx3PSJQ&amp;list=PLShJCpYUN3C3XrdguJiAZrQEnQGH-Sq26&amp;index=13" rel="nofollow">https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=jHOtyx3PSJQ&amp;list=PLShJCpYUN3...</a><p>[2]<a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=IGYxMsHw9iw&amp;list=PLShJCpYUN3C3XrdguJiAZrQEnQGH-Sq26&amp;index=1" rel="nofollow">https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=IGYxMsHw9iw&amp;list=PLShJCpYUN3...</a>
vldmrs10 months ago
Great news ! It would be interesting to see performance comparison for IO-bound tasks like http requests between single-threaded asyncio code and multi-threaded asyncio
pansa210 months ago
PEP703 explains that with the GIL removed, operations on lists such as `append` remain thread-safe because of the addition of per-list locks.<p>What about simple operations like incrementing an integer? IIRC this is currently thread-safe because the GIL guarantees each bytecode instruction is executed atomically.
评论 #40950987 未加载
gnatolf10 months ago
Good to hear. The authors are touching on the journey it is to make Cython continue to work. I wonder how hard it&#x27;ll be to continue to provide bdist packages, or within what timeframe, if at all, Cython can transparently ensure correctness for a no-gil build. Anyone got any insights?
codethief10 months ago
Yesterday someone presented preliminary benchmarks here at EuroPython 2024, comparing no-GIL to sub-interpreters and to multiprocessing. Upshot: This gon&#x27; be good!
earthnail10 months ago
Oh how much this would simplify torch.DataLoader (and its equivalents)…<p>Really excited about this.
throwaway575210 months ago
GVR, you are sorely missed, though I hope you are enjoying life.
nas10 months ago
Very encouraging news!
OutOfHere10 months ago
It has been ready for a few months now, at least since 3.13.0 beta 1 which released on 2024-05-08, although alpha versions had it working too. I don&#x27;t know why this is news <i>now</i>.<p>With it, the single-threaded case is slower.
评论 #40949208 未加载
评论 #40949375 未加载
anacrolix10 months ago
Was ready for this 15 years ago when I loved Python and regularly contributed. At the time, nobody wanted to do it and I got bored and went to Go.