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.

Ask HN: Who's building on Python NoGIL?

141 pointsby grandimam5 months ago
I am interested in knowing the things the community is building specifically taking into account the NoGIL aspect of python. Like is someone building frameworks around using Threads instead of Async?

10 comments

upghost5 months ago
This is going to be bananas for libpython-clj[1]. One of the biggest limiting factors right now is that you can&#x27;t mix Java&#x2F;Clojure concurrency with Python concurrency, you need to have a really clear separation of concurrency models. But with this, you will be able to freely mix Clojure and Python concurrency. Just from a compositional standpoint, Clojure atoms and core.async with Python functions will be fantastic. More practically, this will unlock a lot of performance gains with PyTorch and Tensorflow which historically we&#x27;ve had to lock to single threaded mode. Yay!<p>[1]: <a href="https:&#x2F;&#x2F;github.com&#x2F;clj-python&#x2F;libpython-clj">https:&#x2F;&#x2F;github.com&#x2F;clj-python&#x2F;libpython-clj</a>
评论 #42484955 未加载
评论 #42488728 未加载
bionhoward5 months ago
PyO3 0.23.0 was a big release I’ve been tinkering with extensively. Support for “free-threaded Python” is a headline feature, and I imagine NoGIL Python will be extremely nice for Rust interoperability, so there is definitely interest in that crate. Also could be huge for queueing data for GPUs, api servers, and bulk data fetching.<p>For whatever reason (maybe post 2to3 PTSD), Python community seems not extremely eager to jump on latest versions of Python and it often takes a long time for popular libraries to support the latest and greatest, so I’d recommend patience and baby steps<p><a href="https:&#x2F;&#x2F;github.com&#x2F;PyO3&#x2F;pyo3&#x2F;releases&#x2F;tag&#x2F;v0.23.0">https:&#x2F;&#x2F;github.com&#x2F;PyO3&#x2F;pyo3&#x2F;releases&#x2F;tag&#x2F;v0.23.0</a>
评论 #42483323 未加载
评论 #42493406 未加载
评论 #42495121 未加载
评论 #42493219 未加载
carlsborg5 months ago
Its merged into CPython 3.13 but labeled as experimental.<p>Single threaded cpu bound workloads suffer in benchmarks (vs i&#x2F;o workloads) till they put back the specializing adaptive interpreter (PEP 659) in 3.14. Docs say a 40% hit now, target is 10% at next release.<p>C extensions will have to be re-built and ported to support free threaded mode.<p>Some interesting and impactful bits of open source work for those with a c++ multithreading background.
评论 #42492675 未加载
trollbridge5 months ago
In new code I try to use threads, but certain things like yield which rely on async are simply too common and useful to stop using.<p>So far in production if I need to use multiple cores, I use multiple processes and design apps that way. The discipline this imposes does seem to result in better apps than I wrote in an environment like Java with tons of threads.
评论 #42494025 未加载
throwaway815235 months ago
I&#x27;ve always used threads despite the GIL. I haven&#x27;t tried NoGIL and am waiting to find out how many bugs it surfaces. I do get the impression that multi-threaded Python code is full of hazards that the GIL covers up. There will have to be locks inserted all over the place. CPython should have simply been retired as part of the 2 to 3 transition. It was great in its day, on 1-core machines with the constraints of that era. I have a feeling of tragedy that this didn&#x27;t happen and now it can never be repaired. I probably wouldn&#x27;t use Python for web projects these days. I haven&#x27;t done anything in Elixir yet but it looks like about the best option. (I&#x27;ve used Erlang so I think I have a decent idea of what I&#x27;d be getting into with Elixir).
评论 #42469048 未加载
评论 #42580087 未加载
评论 #42479264 未加载
shlomo_z5 months ago
I have the same question! I love Python and asynchronous stuff, and I do not know too much about threading.<p>Is threading potentially better for IO bound tasks than async?
评论 #42469133 未加载
评论 #42525956 未加载
评论 #42488041 未加载
评论 #42492483 未加载
PaulHoule5 months ago
My RSS reader is written in async Python but I think it was a mistake and I built my image sorter to use gunicorn which means I have to run it inside WSL on Windows but actually it works really well. My &quot;image sorter&quot; is actually a lot of different things (it has a webcrawler in it, a tagging system, will probably take over the RSS reader&#x27;s job someday) but it does an unholy mix of )(i) &quot;things that require significant CPU&quot; (like... math) and (ii) &quot;things that require just a touch of CPU&quot; like serving images.<p>I found that (i) was blocking (ii) making the image sorter unusable.<p>So far though that is processes and not threads.<p>For the last few weeks for the hell of it I&#x27;ve been writing a small and very pedagogical chess playing program in Python (trying to outdo Lisp) and once I got the signs figured out in the alpha-beta negamax algorithm it can now beat my tester most of the time. (When I had the signs wrong it managed to find the fool&#x27;s mate which is not too surprising in retrospect since it looks ahead enough plies)<p>That was my major goal but I&#x27;d also like to try an MCTS chess program which is more of a leap into the unknown. Unlike alpha-beta MCTS can be almost trivially parallelized (run 16 threads of it for, say, 0.1 s, merge the trees, repeat, ...) and threads would be a convenient way to handle concurrency here although multiprocessing out to be good enough. So I am thinking about using a non-GIL Python but on the other hand I could also rewrite in Java and get a 50x or so speedup <i>and</i> great thread support.<p>(Note the problem here is that unlike games where you fill up a board, chess doesn&#x27;t really progress when you play out random moves. With random moves for instance you can&#x27;t reproduce White&#x27;s advantage at the beginning of the game and if your evaluation function can&#x27;t see that you are doing really bad. I need a weak player for the playouts that plays well enough that it can take advantage of situations that real players can take advantage of at least some of the time. A really good move ordering function for an alpha-beta search might do the trick.
tgma5 months ago
Started working on a no-gil gRPC Python implementation but super low priority.<p>Has anyone started deploying nogil at scale in prod?
评论 #42494800 未加载
评论 #42469009 未加载
0xDEADFED55 months ago
Waiting for CFFI or pywin32 free-threaded support since I don&#x27;t have time to work on CFFI myself
Reclaimer5 months ago
trying to make a framework for this called clusterops.<p><a href="https:&#x2F;&#x2F;github.com&#x2F;The-Swarm-Corporation&#x2F;ClusterOps">https:&#x2F;&#x2F;github.com&#x2F;The-Swarm-Corporation&#x2F;ClusterOps</a>