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.

Django 4.1

289 pointsby j4miealmost 3 years ago

11 comments

zzzeekalmost 3 years ago
looking at the release notes and the source, it looks like the asyncio interface is still using the old drivers, like psycopg2 for postgresql, and using a threadpool.<p>we at SQLAlchemy came up with a way to interface asyncio frontend and backend (like asyncpg for the driver) while maintaining all the &quot;in the middle&quot; code as synchronous style. the dark secret is that for this approach you have to use greenlet to propagate the &quot;await&quot; operations. It&#x27;s been in our release for 18 months now with 1M downloads a day and there have been no problems reported with it, so i continue to wonder why nobody else seems to want to look at this approach. one downside which nobody has complained about yet is that it makes profiling tools like cProfile harder to use, but seems not to have come up yet.<p>there&#x27;s also another approach, which is that you rewrite all your &quot;in the middle&quot; code as pure asyncio, then create a dummy task to implement your synchronous API. dark secret for that one is you had to rewrite everything and I&#x27;m not sure if there&#x27;s other performance implications for having awaits all throughout code that&#x27;s running only one task per thread.
评论 #32335028 未加载
评论 #32334491 未加载
评论 #32333592 未加载
评论 #32334636 未加载
nickjjalmost 3 years ago
If anyone is interested I updated my example Django Docker app to 4.1 at: <a href="https:&#x2F;&#x2F;github.com&#x2F;nickjj&#x2F;docker-django-example" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;nickjj&#x2F;docker-django-example</a><p>It includes running Django, Celery, gunicorn, Postgres, Redis, esbuild and Tailwind through Docker and Docker Compose. It&#x27;s set up for development and production.
评论 #32331772 未加载
评论 #32336784 未加载
评论 #32330263 未加载
评论 #32332944 未加载
评论 #32330223 未加载
hansonkd13almost 3 years ago
Great to see improving support for async here. I am a big fan, but IMO python async code is just different from other async langauges. I used async extensively in python and compared to other languages it is a pain to use because unless 100% of the the libs you want support it you will get stuck on some sync library. Async in python is not even a 2nd class citizen. Its more like a 3rd class citizen. Its gets better every year but it is minuscule compared to regular sync code, so very few tutorials mention it and nobody teaches it as the default way of doing things.<p>In order for async to be popular it needs to be the default way of writing python. Right now its an after thought for writing “high performance” python. For example asyncio version of redis got 72,114 downloads this month. The sync version got 26,825,663. Thats not even in the same universe.<p>Historically, using something like gevent is a more drop-in solution for python if you want lightweight threads, but it comes with its own problems. Gevent gives python what Zig has that automatically turns all sync IO calls to async and your app is now magically using greenthreads.<p>However I think gevent in the past was the crutch that prevented a lot of lib authors from writing async libs.
评论 #32332860 未加载
评论 #32334794 未加载
评论 #32333625 未加载
评论 #32335157 未加载
WhatsNamealmost 3 years ago
The most anticipated Django release for me personally. Async ORM access is a massive quality of life improvememt, same for async CBV. The later is also a blocker for Django Rest Framework going async.<p>Sure most CRUD applications work perfectly fine using WSGI, but for anyone using other protocols like WS or MQTT in their app this is kind of a big deal.
评论 #32330567 未加载
评论 #32330708 未加载
评论 #32330189 未加载
评论 #32330067 未加载
评论 #32332565 未加载
BiteCode_devalmost 3 years ago
This is going to make django-ninja even easier to use, so it&#x27;s very welcome.<p>And if you like django and never tried django ninja, it&#x27;s like DRF and FastAPI had a baby: <a href="https:&#x2F;&#x2F;django-ninja.rest-framework.com&#x2F;" rel="nofollow">https:&#x2F;&#x2F;django-ninja.rest-framework.com&#x2F;</a>. You define your endpoints using pydantic type hints, and it generates the API, validators and docs all in one go.
评论 #32332740 未加载
评论 #32334089 未加载
ralmidanialmost 3 years ago
Django is single-handedly responsible for making me fall in love with programming. I am now using Elixir&#x2F;Phoenix and 100% sold on the benefits of working with immutable data, but I still keep an eye on developments in the Python&#x2F;Django ecosystem. Seeing Django edge closer to having a fully async stack is very exciting, and should make it a more viable platform for existing users as well as newcomers.
评论 #32337510 未加载
评论 #32332129 未加载
game_the0ryalmost 3 years ago
Am I bad SWE if I do not care for for async in django?<p>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.<p>FWIW I like django &#x2F; python for a lot of things, just not for performance.
评论 #32331307 未加载
评论 #32331326 未加载
评论 #32331681 未加载
评论 #32331282 未加载
评论 #32333683 未加载
评论 #32331446 未加载
评论 #32333911 未加载
评论 #32343793 未加载
评论 #32331539 未加载
buro9almost 3 years ago
Guess I best upgrade my production side-project from Django 1.5.9
评论 #32330298 未加载
评论 #32337565 未加载
评论 #32332437 未加载
sirodohtalmost 3 years ago
I wonder how popular the async interface will become. I use Python and Django extensively but haven&#x27;t touch any of the async operations.
评论 #32329958 未加载
评论 #32329982 未加载
评论 #32331059 未加载
syastrovalmost 3 years ago
There are a lot of comments about async ORM, but to me the support for application-level (e.g. if you use forms, admin, DRF, Graphene) validation of DB-level constraints is a super cool feature that solves a real pain point - having to duplicate this logic at both levels, or forgetting to do so.
评论 #32340038 未加载
ac130kzalmost 3 years ago
Let&#x27;s see how long it will take for DRF to support async...