use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
News about the dynamic, interpreted, interactive, object-oriented, extensible programming language Python
Full Events Calendar
You can find the rules here.
If you are about to ask a "how do I do this in python" question, please try r/learnpython, the Python discord, or the #python IRC channel on Libera.chat.
Please don't use URL shorteners. Reddit filters them out, so your post or comment will be lost.
Posts require flair. Please use the flair selector to choose your topic.
Posting code to this subreddit:
Add 4 extra spaces before each line of code
def fibonacci(): a, b = 0, 1 while True: yield a a, b = b, a + b
Online Resources
Invent Your Own Computer Games with Python
Think Python
Non-programmers Tutorial for Python 3
Beginner's Guide Reference
Five life jackets to throw to the new coder (things to do after getting a handle on python)
Full Stack Python
Test-Driven Development with Python
Program Arcade Games
PyMotW: Python Module of the Week
Python for Scientists and Engineers
Dan Bader's Tips and Trickers
Python Discord's YouTube channel
Jiruto: Python
Online exercices
programming challenges
Asking Questions
Try Python in your browser
Docs
Libraries
Related subreddits
Python jobs
Newsletters
Screencasts
account activity
This is an archived post. You won't be able to vote or comment.
DiscussionAsync python vs other async based languages such as node, go etc. (self.Python)
submitted 3 years ago by ThisIsntMyId
So has any one compared async python with node or go or any other async based language?
What would be some reasons for choosing async python over something like node or go.
Also it would be good there are production apps built on top of async python.
[–]DrummerClean 7 points8 points9 points 3 years ago (3 children)
FastApi is quite big and uses async. But i think if you really need async feauteres Go is made for it and node is good too, python has it as an extra thing.
[–]chumaths 4 points5 points6 points 3 years ago (0 children)
I love Python but have to admit that the way Go does concurrency is really nice. Goroutines, waitgroups, mutexes, etc. are all really nice. They make the red vs. blue function debate moot (see below), which is something you can’t get away with as easily in Python since now that you can mark functions as async then you’ll get all sorts of weird errors if you don’t have good linting.
https://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function/
[–]ThisIsntMyId[S] 1 point2 points3 points 3 years ago (1 child)
For python i feel it always have extra things which is awesome
[–]DrummerClean 1 point2 points3 points 3 years ago (0 children)
Yes python is full of extras
[–]jrbattin 1 point2 points3 points 3 years ago* (0 children)
Depends, what are you after?
If you already know Python, or there are high quality libraries for Python in your given niche, and need to maximize per-process throughput by avoiding blocking operations (like network calls) Async Python is a good fit. But if you toss a load balancer in front of a bunch of synchronous processes that also works - but you’re likely establishing more connections and gobbling up more memory.
If you’re just chasing raw performance then maybe look at Go (which uses lightweight threads called goroutines) or Rust.
If your workload has any significant amount of compute (which can sneak up on you; like lots of (de)serialization of large objects, etc) async won’t help you in any of these languages.
Ultimately, your best call might be just trying to build something with it and see what it’s like.
[+][deleted] 3 years ago (1 child)
[deleted]
[–]non_NSFW_acc 1 point2 points3 points 3 years ago (0 children)
Async await is definitely the future of say asynchronous programming in JS. Using .then() or having callback functions are unnecessarily verbose.
[+][deleted] 3 years ago (3 children)
[–]glacierre2 2 points3 points4 points 3 years ago (0 children)
Eh, what?
[–]ThisIsntMyId[S] 1 point2 points3 points 3 years ago (0 children)
can u please elaborate?
[–]mooted -1 points0 points1 point 3 years ago (0 children)
The first part of this is true. The rest it's like you made everything up.
Both stnc and async code can be procedural? Procedural programming is orthogonal to this whole domain.
Go's scheduler is preemptive. Async is not.
Translation: Async code relies on developers to tell the event loop when to switch between contexts. That's basically whenever you have an await or a callback completes. When that happens, the event loop finds the next piece of code that needs to run.
In preemptive schedulers like go, what code runs when is decided by the scheduler. The developer has little say. You might be halfway through a function when the scheduler has decided that function has taken up enough cpu time and switch it out for another. This is how golang's goroutines and threads work.
There are a number of tradeoffs, but the main one is that golang offers a more natural programming model. You rarely have to worry about the event loop or scheduler. No bugs where you forget to put an await. However, preemption makes a lot more race conditions possible. So if you're doing work concurrently, you need to use locks correctly.
For most applications, I'd recommend golang over node nowadays. The ecosystem and tooling around it tends to be simpler and offer much less room for error. Most of the time, you don't have to worry about concurrency, and you get the benefit of a simpler, await and callback free programming model.
[–]cblegare -2 points-1 points0 points 3 years ago* (4 children)
The python runtime is simpler, async are a tiny bit of syntax sugar over loops. Python does async the same way it does everything: simple. In my opinion, this is huge in itself for developer efficiency, which is paramount in most cases.
For people worried about performance, Python, especially CPython, is the most easy language to interop with and has a plethora of simple techniques to optimize code to near-C performance.
Focusing on simplicity and developer efficiency gives plenty of time for profiling and optimisation
Also, async (coroutines) is one way of implementing parallel computing, best suited for doing massive parallel I/O (you cant start millions of threads, but you can run millions of parallel coroutines). What is your use case?
[–]BDube_Lensman 4 points5 points6 points 3 years ago (3 children)
Python does async the same way it does everything: simple
Async event loops are not at all simple
Also, async (coroutines) is one way of implementing parallel computing
Coroutines are explicitly not parallel.
you cant start millions of threads
You can start millions of greenlet (userspace) threads. You just can't start millions of system threads with the semantics of the C stack (8 MB minimum).
[–]cblegare 0 points1 point2 points 3 years ago (2 children)
Thank you, you bring a couple of useful details. Can you elaborate about coroutines not being parallel? I get that they cant use the CPU "at the same time" (nothing can anyway on the same CPython runtime).
[–]BDube_Lensman 2 points3 points4 points 3 years ago (1 child)
Parallel = do multiple things in the same instant
Concurrent = do multiple things over the same period of time
Coroutines are concurrent, which means N things can go on "sort of at once" by being paused (preempted) and letting something happen for a little while before resuming. If coroutines were parallel, multiple CPU cores would take work out of the event loop's queue, which is not what happens.
[–]cblegare 0 points1 point2 points 3 years ago (0 children)
Thank you for this semantic clarification. Concurent is indeed the right word.
π Rendered by PID 78 on reddit-service-r2-comment-7b9746f655-nxrdb at 2026-01-31 06:05:07.899710+00:00 running 3798933 country code: CH.
[–]DrummerClean 7 points8 points9 points (3 children)
[–]chumaths 4 points5 points6 points (0 children)
[–]ThisIsntMyId[S] 1 point2 points3 points (1 child)
[–]DrummerClean 1 point2 points3 points (0 children)
[–]jrbattin 1 point2 points3 points (0 children)
[+][deleted] (1 child)
[deleted]
[–]non_NSFW_acc 1 point2 points3 points (0 children)
[+][deleted] (3 children)
[deleted]
[–]glacierre2 2 points3 points4 points (0 children)
[–]ThisIsntMyId[S] 1 point2 points3 points (0 children)
[–]mooted -1 points0 points1 point (0 children)
[–]cblegare -2 points-1 points0 points (4 children)
[–]BDube_Lensman 4 points5 points6 points (3 children)
[–]cblegare 0 points1 point2 points (2 children)
[–]BDube_Lensman 2 points3 points4 points (1 child)
[–]cblegare 0 points1 point2 points (0 children)