TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Django Async: What's new and what's next?

148 点作者 sanketsaurav将近 5 年前

11 条评论

Bedon292将近 5 年前
I love Django &#x2F; Django Rest Framework and have used it for a long time, but we recently dumped it from a project in favor of FastAPI.<p>There is just so many layers of magic in Django, that it was becoming impossible for us to improve the performance to an acceptable level. We isolated the problems to serialization &#x2F; deserialization. Going from DB -&gt; Python object -&gt; JSON response was taking far more time than anything else, and just moving over to FastAPI has gotten us a ~5x improvement in response time.<p>I am excited to see where Django async goes though. Its something I had been looking forward to for a while now.
评论 #24162013 未加载
评论 #24163231 未加载
评论 #24164594 未加载
评论 #24165129 未加载
评论 #24165949 未加载
评论 #24164871 未加载
评论 #24162539 未加载
评论 #24165920 未加载
评论 #24162874 未加载
评论 #24162644 未加载
评论 #24162974 未加载
silviogutierrez将近 5 年前
Great article. But I think this part may need as second look:<p><pre><code> If your views involve heavy-lifting calculations or long-running network calls to be done as part of the request path, it’s a great use case for using async views. </code></pre> That seems true for long-running network calls (IO). But for heavy-lifting calculations? I thought that was <i>the</i> canonical example of situations async won&#x27;t improve. CPU bound and memory bound, after all.
评论 #24161972 未加载
评论 #24161884 未加载
评论 #24164014 未加载
abledon将近 5 年前
Whats the most elegant way for cutting edge Django to do websockets? is it still to &#x27;tack&#x27; on the channels package [0] ?<p>compared to FastAPI[1] I really don&#x27;t want to use it, I only miss the ORM since in FastAPI it looks like you have to manually write the code to insert stuff[2].<p>[0] <a href="https:&#x2F;&#x2F;realpython.com&#x2F;getting-started-with-django-channels&#x2F;" rel="nofollow">https:&#x2F;&#x2F;realpython.com&#x2F;getting-started-with-django-channels&#x2F;</a><p>[1] <a href="https:&#x2F;&#x2F;fastapi.tiangolo.com&#x2F;advanced&#x2F;websockets&#x2F;#create-a-websocket" rel="nofollow">https:&#x2F;&#x2F;fastapi.tiangolo.com&#x2F;advanced&#x2F;websockets&#x2F;#create-a-w...</a><p>[2] <a href="https:&#x2F;&#x2F;fastapi.tiangolo.com&#x2F;tutorial&#x2F;sql-databases&#x2F;#create-data" rel="nofollow">https:&#x2F;&#x2F;fastapi.tiangolo.com&#x2F;tutorial&#x2F;sql-databases&#x2F;#create-...</a>
评论 #24164576 未加载
评论 #24164833 未加载
评论 #24164205 未加载
评论 #24163472 未加载
hyuuu将近 5 年前
time and time again, whenever I start a new project, Django has always been my go-to choice after analyzing the alternatives. I&#x27;ve worked on large scale, mono-repo, billion users to side projects over the weekend, Django really stay true to the batteries included philosphy.
dec0dedab0de将近 5 年前
I think the article and some of the comments are not really looking at this the right way.<p>For most things you&#x27;re probably better off &quot;doing the work&quot; in a celery task, regardless if it is IO bound or CPU bound. Then use web sockets just for your status updates&#x2F;progress bar, instead of having your front end poll on a timer.
评论 #24164532 未加载
honkycat将近 5 年前
I love django, have not used it in years though. I&#x27;ve been in JavaScript land.<p>I&#x27;m consistently surprised that there are not awesome web frameworks in JavaScript similar to Django
评论 #24165912 未加载
评论 #24166016 未加载
评论 #24165803 未加载
djstein将近 5 年前
I’ve seen lots of blog posts, even the Django docs, saying async is available but still haven’t seen any real world examples yet. Do any exist?<p>Also, I still haven’t seen how the async addition will work with Class Based Views. Also, Django Rest Framework is still considering spending time for support. Until these two use cases are viable many users won’t benefit.
kissgyorgy将近 5 年前
&gt; If your views involve heavy-lifting calculations ...<p>Nooo, not at all. Your tasks should be I&#x2F;O bound, not CPU bound to take advantage of asyncio. Maybe the async server using multiple threads with multiple event loops, but don&#x27;t ever do a CPU-heavy task in an event loop because you just invalidated using asyncio completely.
IgorPartola将近 5 年前
Looking at the async view example, at what point can we just drop async&#x2F;await keywords and just have Python assume that everything is asynchronous?
评论 #24166008 未加载
leafboi将近 5 年前
Wasn&#x27;t there an article about how the async syntax was benchmarked to actually be <i>slower</i> than the traditional way of using threads? What&#x27;s the current story on python async?<p>reference: <a href="http:&#x2F;&#x2F;calpaterson.com&#x2F;async-python-is-not-faster.html" rel="nofollow">http:&#x2F;&#x2F;calpaterson.com&#x2F;async-python-is-not-faster.html</a>
评论 #24162183 未加载
评论 #24161888 未加载
评论 #24163649 未加载
评论 #24161648 未加载
评论 #24162074 未加载
评论 #24161713 未加载
评论 #24162009 未加载
ArtDev将近 5 年前
I had a bad experience with Django. I found it cluttered and slow. I really wanted to like it. It might seem funny but a more straightforward framework like Symfony didn&#x27;t get it in the way and ended up much faster. Python should be much much faster than PHP but I guess the framework matters a lot too.
评论 #24166374 未加载