News for hackers. Stuff that matters.
Re:Python Asyncio: The Complete Guide by kissgyorgy on Thursday November 10, 2022 @11:00AM (#33548369)
I'm pretty sure a lot of people don't understand the tradeoffs and don't really need concurrent code. There are really only a couple of use-cases where it's really handy: for example an API gateway, where you only get and send HTTP requests. Other than that, I don't see how it worth the insane complexity (compared to sync code).

You can write web servers in a sync manner; Flask, Django is way better if you only need an API, choosing FastAPI for a simple REST API is a huge mistake.

Re:Python Asyncio: The Complete Guide by thunky on Thursday November 10, 2022 @12:55PM (#33550438)
> FastAPI for a simple REST API is a huge mistake

FastAPI can be sync or async, although sync will have "a small performance penalty"

https://github.com/tiangolo/fastapi/issues/260#issuecomment-...

Re:Python Asyncio: The Complete Guide by walls on Thursday November 10, 2022 @01:18PM (#33550771)
What kind of APIs are you writing that don’t involve db lookups or calls to other services?
Re:Python Asyncio: The Complete Guide by samwillis on Thursday November 10, 2022 @01:43PM (#33551138)
Asyncio does not make your db calls or io faster, it does make your code more complex.

The only thing async io gives you is scalability of many MANY concurrent io operations. You have to either be pushing seriously large traffic or doing a lot of long running websocket/sse/long polling type requests.

The only other use case is lots of truly concurrent io within one request/response cycle. But again that is unusual, most apis have low single digit db queries that are usually dependent on one another removing any advantage of async.

Re:Python Asyncio: The Complete Guide by fprct on Friday November 11, 2022 @04:03AM (#33558571)
> The only other use case is lots of truly concurrent io within one request/response cycle. But again that is unusual, most apis have low single digit db queries that are usually dependent on one another removing any advantage of async.

Why just "within one cycle"? What about situation where you spend 1s in single db query and are 100ms cpu bound during request handling?

Re:Python Asyncio: The Complete Guide by samwillis on Saturday November 12, 2022 @05:29AM (#33571829)
Transitional multithreaded Python web servers handle that very well and have for decades, you shouldn't need to manually handle yealding in simple cases in your application code.

The point is asyncio is to have find grade control of yealding.

Re:Python Asyncio: The Complete Guide by mixmastamyk on Thursday November 10, 2022 @01:54PM (#33551302)
Choosing fastapi for a fast api is a mistake?
Re:Python Asyncio: The Complete Guide by kissgyorgy on Thursday November 10, 2022 @02:26PM (#33551735)
Choosing unnecessary complexity for a simple task is a mistake. FastAPI is not faster than Django or Flask for a single request, quite the opposite.
Re:Python Asyncio: The Complete Guide by hdjjhhvvhga on Thursday November 10, 2022 @02:34PM (#33551859)
Re:Python Asyncio: The Complete Guide by lucasyvas on Thursday November 10, 2022 @11:40PM (#33557365)
How is Django less complex than FastAPI? Django was built for monolithic web applications - it does fine with REST, but your position is backward. FastAPI is purpose built for smaller APIs