<p>Which is faster, python webpages or php webpages?</p>

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

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

<p>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.</p>

[{'answer_id': 77093, 'author': 'UnkwnTech', 'author_id': 115, 'author_profile': 'https://Stackoverflow.com/users/115', 'pm_score': 2, 'selected': False, 'text': "<p>If it ain't broke don't fix it.</p>\n\n<p>Just write a quick test, but bear in mind that each language will be faster with certain functions then the other.</p>\n"}, {'answer_id': 77112, 'author': 'Aeon', 'author_id': 13289, 'author_profile': 'https://Stackoverflow.com/users/13289', 'pm_score': 0, 'selected': False, 'text': '<p>The only right answer is "It depends". There\'s a lot of variables that can affect the performance, and you can optimize many things in either situation.</p>\n'}, {'answer_id': 77166, 'author': 'Peter Bailey', 'author_id': 8815, 'author_profile': 'https://Stackoverflow.com/users/8815', 'pm_score': 2, 'selected': False, 'text': '<p>You need to be able to make a business case for switching, not just that "it\'s faster".  If a site built on technology B costs 20% more in developer time for maintenance over a set period (say, 3 years), it would likely be cheaper to add another webserver to the system running technology A to bridge the performance gap.</p>\n\n<p>Just saying "we should switch to technology B because technology B is <em>faster!</em>" doesn\'t really work.</p>\n\n<p>Since Python is far less ubiquitous than PHP, I wouldn\'t be surprised if hosting, developer, and other maintenance costs for it (long term) would have it fit this scenario.</p>\n'}, {'answer_id': 77174, 'author': 'indentation', 'author_id': 7706, 'author_profile': 'https://Stackoverflow.com/users/7706', 'pm_score': 2, 'selected': False, 'text': '<p>It\'s about the same. The difference shouldn\'t be large enough to be the reason to pick one or the other. Don\'t try to compare them by writing your own tiny benchmarks (<code>"hello world"</code>) because you will probably not have results that are representative of a real web site generating a more complex page.</p>\n'}, {'answer_id': 77220, 'author': 'SCdF', 'author_id': 1666, 'author_profile': 'https://Stackoverflow.com/users/1666', 'pm_score': 2, 'selected': False, 'text': "<p>PHP and Python are similiar enough to not warrent any kind of switching.</p>\n\n<p>Any performance improvement you might get from switching from one language to another would be vastly outgunned by simply not spending the money on converting the code (you don't code for free right?) and just buy more hardware.</p>\n"}, {'answer_id': 77297, 'author': 'Rob', 'author_id': 3542, 'author_profile': 'https://Stackoverflow.com/users/3542', 'pm_score': 5, 'selected': False, 'text': "<p>There's no point in attempting to convince your employer to port from PHP to Python, especially not for an existing system, which is what I think you implied in your question.</p>\n\n<p>The reason for this is that you already have a (presumably) working system, with an existing investment of time and effort (and experience). To discard this in favour of a trivial performance gain (not that I'm claiming there would be one) would be foolish, and no manager worth his salt ought to endorse it.</p>\n\n<p>It may also create a problem with maintainability, depending on who else has to work with the system, and their experience with Python.</p>\n"}, {'answer_id': 79744, 'author': 'Ross', 'author_id': 14794, 'author_profile': 'https://Stackoverflow.com/users/14794', 'pm_score': 8, 'selected': True, 'text': '<p>It sounds like you don\'t want to compare the two <strong>languages</strong>, but that you want to compare two <strong>web systems</strong>.</p>\n\n<p>This is tricky, because there are many variables involved.</p>\n\n<p>For example, Python web applications can take advantage of <a href="http://code.google.com/p/modwsgi/" rel="noreferrer">mod_wsgi</a> 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).</p>\n\n<p>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 <a href="http://eaccelerator.net/" rel="noreferrer">eAccelerator</a>) to much the same effect.</p>\n\n<p>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.</p>\n\n<p>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.</p>\n'}, {'answer_id': 510276, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 2, 'selected': False, 'text': '<p>an IS organization would not ponder this unless availability was becoming an issue.</p>\n\n<p>if so the case, look into replication, load balancing and lots of ram.</p>\n'}, {'answer_id': 2412215, 'author': 'notageek', 'author_id': 289967, 'author_profile': 'https://Stackoverflow.com/users/289967', 'pm_score': -1, 'selected': False, 'text': '<p>I had to come back to web development at my new job, and, if not Pylons/Python, maybe I would have chosen to live in jungle instead :) In my subjective opinion, PHP is for kindergarten, I did it in my 3rd year of uni and, I believe, many self-respecting (or over-estimating) software engineers will not want to be bothered with PHP code. </p>\n\n<p>Why my employers agreed? We (the team) just switched to Python, and they did not have much to say. The website still is and will be PHP, but we are developing other applications, including web, in Python. Advantages of Pylons? You can integrate your python libraries into the web app, and that is, imho, a huge advantage.</p>\n\n<p>As for performance, we are still having troubles.</p>\n'}, {'answer_id': 33627050, 'author': 'RubbelDeCatc', 'author_id': 2504554, 'author_profile': 'https://Stackoverflow.com/users/2504554', 'pm_score': 3, 'selected': False, 'text': '<p>I would assume that PHP (>5.5) is faster and more reliable for complex web applications because it is optimized for website scripting.</p>\n\n<p>Many of the benchmarks you will find at the net are only made to prove that the favoured language is better. But you can not compare 2 languages with a mathematical task running X-times. For a real benchmark you need two comparable frameworks with hundreds of classes/files an a web application running 100 clients at once.</p>\n'}]
['https://Stackoverflow.com/questions/77086', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/13778/']