python网页还是php网页,哪个更快? [英] Which is faster, python webpages or php webpages?

查看:88
本文介绍了python网页还是php网页,哪个更快?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

python网页或php网页哪个更快?

有人知道塔架(或任何其他框架)的速度与用php制作的类似网站相比如何吗?

我知道通过cgi为python基本网页提供服务比php慢,因为每次启动时间都长.

我喜欢使用挂架,但如果它比php慢,我仍然会使用它.但是,如果挂架比php快,我也许可以最终说服我的雇主允许我将网站转换为挂架.

解决方案

听起来您不想比较这两种语言,但是您想比较两种网络系统.

这很棘手,因为其中涉及许多变量.

例如,Python Web应用程序可以利用 mod_wsgi 与Web服务器进行通讯,这比PHP与Web服务器进行任何典型通信的方式都要快(如果使用Apache,即使mod_php最终也会变慢,因为Apache只能将Prefork MPM与mod_php一起使用,而不是像Worker那样使用多线程MPM). /p>

还有代码编译的问题.如您所知,每次文件更改时,都会在运行文件时将Python实时编译为字节码(.pyc文件).因此,在第一次运行Python文件之后,将跳过编译步骤,并且Python解释器仅获取预编译的.pyc文件.因此,有人可能会说Python比PHP具有天生的优势.但是,可以为PHP网站安装优化器和缓存系统(我最喜欢的是 eAccelerator ). >

通常,存在足够的工具,以便一个工具可以执行另一工具可以执行的所有操作.当然,正如其他人提到的那样,切换语言在业务案例中不仅涉及速度.我们的现任雇主有一个用oCaml编写的应用程序,事实证明这是一个错误,因为原始作者离开了公司,没有其他人愿意碰它.同样,PHP网络社区比Python网络社区大得多.网站托管服务比Python支持更有可能提供PHP支持;等

但是回到速度.您必须认识到,这里的速度问题涉及许多运动部件.幸运的是,这些部件中的许多部件都可以独立优化,从而为您提供了各种途径来提高性能.

Which is faster, python webpages or php webpages?

Does anyone know how the speed of pylons(or any of the other frameworks) compares to a similar website made with php?

I know that serving a python base webpage via cgi is slower than php because of its long start up every time.

I enjoy using pylons and I would still use it if it was slower than php. But if pylons was faster than php, I could maybe, hopefully, eventually convince my employer to allow me to convert the site over to pylons.

解决方案

It sounds like you don't want to compare the two languages, but that you want to compare two web systems.

This is tricky, because there are many variables involved.

For example, Python web applications can take advantage of mod_wsgi to talk to web servers, which is faster than any of the typical ways that PHP talks to web servers (even mod_php ends up being slower if you're using Apache, because Apache can only use the Prefork MPM with mod_php rather than multi-threaded MPM like Worker).

There is also the issue of code compilation. As you know, Python is compiled just-in-time to byte code (.pyc files) when a file is run each time the file changes. Therefore, after the first run of a Python file, the compilation step is skipped and the Python interpreter simply fetches the precompiled .pyc file. Because of this, one could argue that Python has a native advantage over PHP. However, optimizers and caching systems can be installed for PHP websites (my favorite is eAccelerator) to much the same effect.

In general, enough tools exist such that one can pretty much do everything that the other can do. Of course, as others have mentioned, there's more than just speed involved in the business case to switch languages. We have an app written in oCaml at my current employer, which turned out to be a mistake because the original author left the company and nobody else wants to touch it. Similarly, the PHP-web community is much larger than the Python-web community; Website hosting services are more likely to offer PHP support than Python support; etc.

But back to speed. You must recognize that the question of speed here involves many moving parts. Fortunately, many of these parts can be independently optimized, affording you various avenues to seek performance gains.

这篇关于python网页还是php网页,哪个更快?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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