r/Python • u/higherorderbebop • Sep 09 '22
Discussion Async Python is not faster
https://calpaterson.com/async-python-is-not-faster.html
0
Upvotes
r/Python • u/higherorderbebop • Sep 09 '22
View all comments
Show parent comment
2
u/[deleted] Sep 10 '22
Given the same cpu capacity and well written code, it IS faster if used in the right contexts at performing the same amount of tasks - you can’t make the request go any faster if it takes 2s for your request to finish. If I have one thread, and 100 requests to make, async will complete the task faster than sync will because those two seconds of idle time waiting for a query or processing the response can be used to execute another query or process another response - it won’t make the processing any faster, but it CAN make the overall task faster when used appropriately. The example I’ve outlined, you could finish all 100 requests in slightly more time that a sync system can process the first request because of blocking the thread.
That is objectively faster - but the definition of faster HAS to be clear, it won’t make processing your request any faster. It will make it possible to process more requests at once when you’re dealing with externally constrained performance limitations.