News for hackers. Stuff that matters.
Re:Django 4.1 by game_the0ry on Wednesday August 03, 2022 @09:04AM (#32331157)
Am I bad SWE if I do not care for for async in django?

I am sure a a lot of django devs will like it, but if I need the performance that I would get from going async, I would not being using django as my web framework.

FWIW I like django / python for a lot of things, just not for performance.

Re:Django 4.1 by ralmidani on Wednesday August 03, 2022 @09:18AM (#32331307)
Enabling async means those already invested in Django can do more on one machine without a complete rewrite, and those considering it can adopt it with fewer reservations. There will always be more scalable platforms out there, but enabling async with Django helps it serve the “sweet spot” in terms of both ergonomics and scalability.
Re:Django 4.1 by roflyear on Wednesday August 03, 2022 @12:38PM (#32333940)
Probably not. If you need async for DB "stuff" to take advantage of your resources, I think it is a rare thing, and likely you would not want to use the ORM anyway, and then can just do whatever you want without it.
Re:Django 4.1 by rossdavidh on Wednesday August 03, 2022 @09:20AM (#32331326)
If you have one part of your app that needs async, but 90% of it is in the sweet spot for Django, then this could be important.
Re:Django 4.1 by Demiurge on Wednesday August 03, 2022 @09:54AM (#32331681)
No, I agree with you. It's 2022 and I have thought only once that it would be neat to have async methods from Django, but only as some 'cool thing to try'.

I don't actually actually know if there would be any substantial benefit. It's like when I tried PyPy as my django interpreter. It gave a few percent speed increase in "real world" but created extra work for deployment.

I've been using Django non-stop from 0.96, and it just works, and you can build around it. If I was running a trading clearing house, or Instagram, I'd probably care about marginal improvements, and then use another language. But for Django, just tuning the workers per server node, and using django-rq jobs works really well.

Kudos for the enthusiasts working on this though, because 'async' is a new Python feature/meme, and supporting it is just being a good ecosystem player.

Re:Django 4.1 by nilsbunger on Wednesday August 03, 2022 @10:29AM (#32332190)
> If I was running a trading clearing house, or Instagram, I'd probably care about marginal improvements, and then use another language.

Ha, Instagram was written in Django!

Re:Django 4.1 by Demiurge on Wednesday August 03, 2022 @11:22AM (#32332972)
Thats why I mentioned it, lol. I figured a few percentage points improvements in perf for Instagram == $$$
Re:Django 4.1 by collinmanderson on Wednesday August 03, 2022 @10:41AM (#32332399)
Right, though they're stuck on 1.8 (upgraded to 1.8 only so they could use python3), and really just use it for request/response/views, not ORM or anything else.
Re:Django 4.1 by throwaway_4ever on Thursday August 04, 2022 @08:34PM (#32350106)
Are they using DRF? Because obviously mobile app can't use templates and Django doesn't default support REST endpoints, does it?
Re:Django 4.1 by collinmanderson on Friday August 05, 2022 @09:11AM (#32355595)
> Django doesn't default support REST endpoints, does it?

You just have to manually call json.parse(request.body) for incoming requests and return JsonResponse(data). And you generally need to serialize the data yourself.

Django does have some built-in model serialization, but that's mostly for import/export data, not really for sending to the browser.

Re:Django 4.1 by bastawhiz on Wednesday August 03, 2022 @09:16AM (#32331282)
Async doesn't make your code faster, though there are cases where it lets you handle more requests with a single server (especially if you have code that is async). But moreover, if you have libraries that use async code, it's really not ideal if the thing that runs those libraries isn't async. You don't have to like or want it, but it's there for the folks who want or need it.
Re:Django 4.1 by jmconfuzeus on Wednesday August 03, 2022 @12:18PM (#32333683)
I don't care about it either. Who's actually doing a ton of querying in their views? We have materialized views for that.

I wish Django followed Ruby on Rails a little by focusing on improved developer experience instead of niche features that only a few mega corps need.

Re:Django 4.1 by znpy on Wednesday August 03, 2022 @09:30AM (#32331446)
> Am I bad SWE if I do not care for for async in django?

In a way, yes.

Async in django means that with relatively minor adjustments to your codebase you may significantly increase your requests over time throughput.

And as someone else pointed out, if you have database queries that do not depend on each other you can effectively wait for their results in parallel, which might this time not only increase throughput but also lower the total request time.

It’s a very valuable development that brings significant gain for relatively minor changes.

If you are a professional django developer you should not dismiss such developments like that.

Re:Django 4.1 by roflyear on Wednesday August 03, 2022 @12:36PM (#32333911)
No. Async in Python is... eh. Rarely is it useful. Sometimes it is, though! Use it when it is useful...
Re:Django 4.1 by Spivak on Wednesday August 03, 2022 @02:18PM (#32335138)
Twisted is a pretty dope though. Wouldn’t migrate a non-async app to async but would absolutely look at async-by-default for new projects.
Re:Django 4.1 by roflyear on Thursday August 04, 2022 @10:24AM (#32343324)
I love twisted and I have used it in some created ways, but I don't think I'd ever do async-by-default. Just too many headaches.
Re:Django 4.1 by stevenally on Thursday August 04, 2022 @10:59AM (#32343793)
It obviously has it’s used, but I have never needed async in my 17 years as a web programmer…
Re:Django 4.1 by froza on Wednesday August 03, 2022 @09:41AM (#32331539)
it seems most useful for those who want to add simple Websocket support to the existing Django codebase and use the ORM without too much pain