Django和原始Python之间的性能 [英] Performance between Django and raw Python

查看:85
本文介绍了Django和原始Python之间的性能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道使用简单的python文件制作网页和使用Django之间的性能差异。我只是想知道两者之间是否有显着差异。感谢

I was wondering what the performance difference is between using plain python files to make web pages and using Django. I was just wondering if there was a significant difference between the two. Thanks

推荐答案

Django是纯Python。所以每个like语句或表达式的执行时间将是一样的。需要理解的是,许多组件放在一起,为网络开发提供了几个优点:

Django IS plain Python. So the execution time of each like statement or expression will be the same. What needs to be understood, is that many many components are put together to offer several advantages when developing for the web:


  • 删除常见任务

  • 算法的正确性(cookies /会话,加密)

  • 减少自定义代码(由于图书馆)直接影响到错误数量,开发时间等。

  • 以下约定导致团队合作的改善,以及了解代码的能力。

  • 可插拔性;创建或找到可以以最小集成成本使用的新功能块

  • 文档和帮助;许多人了解技术,并能够帮助(StackOverflow?)

  • Removal of common tasks into libraries (auth, data access, templating, routing)
  • Correctness of algorithms (cookies/sessions, crypto)
  • Decreased custom code (due to libraries) which directly influences bug count, dev time etc
  • Following conventions leads to improved team work, and the ability to understand code
  • Plug-ability; Create or find new functionality blocks that can be used with minimal integration cost
  • Documentation and help; many people understand the tech and are able to help (StackOverflow?)

现在,如果要从头开始编写自己的网站,您需要至少实现几个组件。除了花费非常大的时间来开发您的网站,您还会失去上述的大部分优势。 Django和其他语言的其他Web框架,旨在提供常见的东西,让您直接了解业务需求。

Now, if you were to write your own site from scratch, you'd need to implement at least several components yourself. You also lose most of the above benefits unless you spend an extraordinary amount of time developing your site. Django, and other web frameworks for every other language, are designed to provide the common stuff, and let you get straight to work on business requirements.

如果你曾经爆炸在Web框架崛起之前,PHP中的自定义会话代码和数据访问代码,您甚至不会想到与框架相关的性能成本,使您的工作变得有趣,并且易于(y)ier。

If you ever banged out custom session code and data access code in PHP before the rise of web frameworks, you won't even think of the performance cost associated with a framework that makes your job interesting and eas(y)ier.

现在,Django发布了大量的组件。它的设计方式大部分时间都不会影响你。然而,对于每个请求执行惊人的代码量。如果您使用Django构建一个网站,并且性能不会下降,您可以随意删除所有不需要的位。或者,您可以使用slimpython框架。

Now, that said, Django ships with a LOT of components. It is designed in such a way that most of the time, they won't affect you. Still, a surprising amount of code is executed for each request. If you build out a site with Django, and the performance just doesn't cut it, you can feel free to remove all the bits you don't need. Or, you can use a 'slim' python framework.

真的只是使用Django。真是太棒了它支持许多网站,比您(或我)将建立的任何数百万的网站。有一些方法可以显着提高性能,例如利用缓存,而不是优化通过自定义中间件的循环。

Really, just use Django. It is quite awesome. It powers many sites millions times larger than anything you (or I) will build. There are ways to improve performance significantly, like utilizing caching, rather than optimizing a loop over custom Middleware.

这篇关于Django和原始Python之间的性能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆