问题描述
是否可以优化使用cython在Django中开发的关键任务应用程序的速度?
Is it possible to optimize speed of a mission critical application developed in Django with Cython?
最近我在互联网上阅读到Cython可以转换Python代码像速度一样。
Recently I have read on the internet, that Cython can turn a Python code to C like speed. Is this possible with Django?
推荐答案
这是令人怀疑的。
大多数Web应用程序响应时间是必须单独下载的非HTML元素。通常的经验法则是每个HTML页面8个静态文件。 (.CSS,.JS,图像等)
Most of a web application response time is the non-HTML elements that must be downloaded separately. The usual rule of thumb is 8 static files per HTML page. (.CSS, .JS, images, etc.)
由于这些静态内容都不来自Django,因此您的大多数Web应用程序时间轴都是Apache(或Nginx)或Django以外的其他服务器软件。)
Since none of that static content comes from Django, most of your web application's time-line is Apache (or Nginx or some other server software outside Django).
仅查看生成HTML的时间时,您会发现大部分时间都花在等待数据库上(即使它是内存中的SQLite,您也会看到数据库倾向于控制时间轴)
When looking at just the time to produce the HTML, you'll find that most of the time is spent waiting for the database (even if it's in-memory SQLite, you'll see that the database tends to dominate the timeline)
当您使Apache和数据库快速运行时,然后-直到那时-您才能考虑Python元素。
When you're through making Apache and the database go fast, then -- and only then -- you can consider the Python elements.
底线。不要浪费您的时间来使Django和Python更快运行。
Bottom Line. Don't waste any of your time on making Django and Python go faster.
这篇关于在Django中使用Cython。是否有意义?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!