472,373 Members | 2,009 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,373 software developers and data experts.

Python vs. Perl vs. PHP?

Hello,

I am an avid user of PHP and I am just fooling around with Python for
now. I originally wanted to know which one is faster. As in, works
faster. So far, I think PHP is the fastest for dynamic web-content.
Am I wrong?
Jul 18 '05 #1
17 15433
fa****@jaredweb.com (Fazer) writes:
Hello,

I am an avid user of PHP and I am just fooling around with Python for
now. I originally wanted to know which one is faster. As in, works
faster. So far, I think PHP is the fastest for dynamic web-content.
Am I wrong?


yes for two reasons, one relative, one more objective :

- you'll write cleaner and shorter programs with python, so more easy to
optimize
- when you'll really need speed, you'll write standalone web-server with
python, and so a lot more eficient and fast in high trafic.

I've rewrite my "high" trafic web site from php to python and gain 10x of
speed.

--
William Dode - http://flibuste.net
Jul 18 '05 #2
Fazer wrote:
Hello,

I am an avid user of PHP and I am just fooling around with Python for
now. I originally wanted to know which one is faster. As in, works
faster. So far, I think PHP is the fastest for dynamic web-content.
Am I wrong?


Definitely. See here:

http://www.bagley.org/~doug/shootout/craps.shtml

Python is place 13, with a speed index of 578. PHP is second last (before
bash) and has a speed index of 197.

Besides that, PHP is a really ugly language - not only to the eye (which is
admittedly a matter of taste), but a friend of mine currently implements a
PHP->C-Compiler had delved deep into the language implementation - and it
_is_ ugly.

I expirienced mayor flaws in PHP 4.0.x, where my declared functions in a
6000 line include vanished from time to time - repeating the request
sometimes solved the problem. That was really nasty.

Regards,

Diez
Jul 18 '05 #3
"Diez B. Roggisch" <de************@web.de> writes:
Fazer wrote:
Hello,

I am an avid user of PHP and I am just fooling around with Python for
now. I originally wanted to know which one is faster. As in, works
faster. So far, I think PHP is the fastest for dynamic web-content.
Am I wrong?


Definitely. See here:

http://www.bagley.org/~doug/shootout/craps.shtml


has somebody tried to run this bench with python2.3 ?

--
William Dode - http://flibuste.net
Jul 18 '05 #4
"Diez B. Roggisch" <de************@web.de> wrote in message news:<bg*************@news.t-online.com>...
Fazer wrote:
Hello,

I am an avid user of PHP and I am just fooling around with Python for
now. I originally wanted to know which one is faster. As in, works
faster. So far, I think PHP is the fastest for dynamic web-content.
Am I wrong?


Definitely. See here:

http://www.bagley.org/~doug/shootout/craps.shtml

Python is place 13, with a speed index of 578. PHP is second last (before
bash) and has a speed index of 197.

Besides that, PHP is a really ugly language - not only to the eye (which is
admittedly a matter of taste), but a friend of mine currently implements a
PHP->C-Compiler had delved deep into the language implementation - and it
_is_ ugly.

I expirienced mayor flaws in PHP 4.0.x, where my declared functions in a
6000 line include vanished from time to time - repeating the request
sometimes solved the problem. That was really nasty.

Regards,

Diez


Wow, thanks for link! I will use it as hard proof to lure some of my
friends in using Python! ;-)

This is a little off-topic, but I wish to know how would you turn a
string (or data from a text-file) into an array? For example, maybe
turn each \n into an array.

So a string like:

"This is line 1
This is line 2
This is line 3"

And so when you read that into a list called text text[0] would the
"This is line 1".

Thank you once again.
Jul 18 '05 #5
Nevermind. I RTFM :-) .
Jul 18 '05 #6
In article <7b**************************@posting.google.com >,
Fazer <fa****@jaredweb.com> wrote:

This is a little off-topic, but I wish to know how would you turn a
string (or data from a text-file) into an array? For example, maybe
turn each \n into an array.

So a string like:

"This is line 1
This is line 2
This is line 3"

And so when you read that into a list called text text[0] would the
"This is line 1".


s.split('\n')
--
Aahz (aa**@pythoncraft.com) <*> http://www.pythoncraft.com/

This is Python. We don't care much about theory, except where it intersects
with useful practice. --Aahz
Jul 18 '05 #7
Diez B. Roggisch wrote:
http://www.bagley.org/~doug/shootout/craps.shtml

Python is place 13, with a speed index of 578. PHP is second last (before
bash) and has a speed index of 197.


Those benchmarks are doubly useless for the question at hand. Firstly,
they only test command line applications. Secondly, PHP is compiled
without optimizations because the rules state that only the default
configuration can be used. See question 8 of the FAQ:

http://www.bagley.org/~doug/shootout/faq.shtml
Graham

Jul 18 '05 #8
Fazer wrote:
[...] I am basically looking for a FAST
alternative to PHP meaning the responce time is fast. Do you think
that Python with using the CGI module is a good solution?


No, CGI is not a good solution in this case, no matter what the language
(except those perverts who use something like C with dietlibc for this).

The base technology to make web requests fast in Python is something
like mod_python or a Python application server. On top of this I'd
recommend you use a Python web framework, of which there are numerous
ones. The hard part is to evaluate them and choose one.

FWIW I'm currently using Quixote running with mod_scgi against Apache,
mostly because I was fed up with the (lack of) Webware documentation,
which I tried first.

-- Gerhard

Jul 18 '05 #9
Gerhard Häring <gh@ghaering.de> wrote in message news:<ma*********************************@python.o rg>...
Fazer wrote:
[...] I am basically looking for a FAST
alternative to PHP meaning the responce time is fast. Do you think
that Python with using the CGI module is a good solution?


No, CGI is not a good solution in this case, no matter what the language
(except those perverts who use something like C with dietlibc for this).

The base technology to make web requests fast in Python is something
like mod_python or a Python application server. On top of this I'd
recommend you use a Python web framework, of which there are numerous
ones. The hard part is to evaluate them and choose one.

FWIW I'm currently using Quixote running with mod_scgi against Apache,
mostly because I was fed up with the (lack of) Webware documentation,
which I tried first.

-- Gerhard

Thanks for the reply! I think I am going to give mod_python a try.
Would I have to be root to install mod_python? Because that's one of
my biggest concerns. I don't have root and I don't want to work on my
windows machine since I am kind of more comfortable working on a Linux
platform.

Basically, most of my Python scripts would just be accessing the MySQL
database and just printing out various data.
Jul 18 '05 #10
Fazer wrote:
Thanks for the reply! I think I am going to give mod_python a try.
Would I have to be root to install mod_python?
Either that or you need to have the privileges to compile Apache +
mod_python and run it on a nonprivileged port (> 1024).
Because that's one of
my biggest concerns. I don't have root and I don't want to work on my
windows machine since I am kind of more comfortable working on a Linux
platform. [...]


mod_python works on Windows as well. The harder part is finding a web
hoster that will host mod_python apps (pythonhosting.com comes to mind).
I personally find it much easier to learn about system administration
and get my own dedicated server for EUR 39/month.

-- Gerhard

Jul 18 '05 #11
Hi,
Compared to Apache 2.0 with PHP/Zend & Accelerator? I honestl don't think
so. When PHP is compiled to native code it is as fast as Java or C.


There is no such thing like a native compiler for PHP. If you're speaking of
the ZEND compiler - AFAIK that one just does some parse tree caching. As I
mentioned before, a friend of mine works on a php->C (and then native, of
course) compiler.

One thing he has to do is to recreate all the library bindings. These are
really slow implemented in PHP - has something to do with the
parameter-passing. And thats something the ZEND compiler doesn't speed up.

Another thing is PHP session mechanism - the simply persist every session to
the filesystem. Sure, there are FS-Caches, but neverless thats not as fast
as imaginable...

And what do you mean by "As fast as Java or C"? There is a huge difference
in speed between these two.

Not that I think that speed matters much here - usually, the bandwidth,
process creation time and database queries are the bottlenecks.

Regards,

Diez
Jul 18 '05 #12
>> Definitely. See here:

http://www.bagley.org/~doug/shootout/craps.shtml


has somebody tried to run this bench with python2.3 ?


I just picked a few (heapsort.python, methcall.python, objinst.python) tests
and run them on my local machine using 2.2 and 2.3.

The results are that 2.3 seems to need 60-70% of cpu time. Looks good!

time heapsort.python2.3 80000
real 0m4.779s
user 0m3.540s
sys 0m0.000s

time heapsort.python2.2 80000
real 0m5.655s
user 0m5.510s
sys 0m0.030s

Mind you: I didn't do a full benchmarking and didn't even try so!

Diez
Jul 18 '05 #13
> I personally find it much easier to learn about system administration
and get my own dedicated server for EUR 39/month.


39? Where do you get such a good deal?
Jul 18 '05 #14
fa****@jaredweb.com (Fazer) writes:
I personally find it much easier to learn about system administration
and get my own dedicated server for EUR 39/month.


39? Where do you get such a good deal?


15EUR/month on http://lost-oasis.fr i write about them because they make a lot
of contributions to open-source...

--
William Dode - http://flibuste.net
Jul 18 '05 #15
Wilk wrote:
fa****@jaredweb.com (Fazer) writes:

I personally find it much easier to learn about system administration
and get my own dedicated server for EUR 39/month.


39? Where do you get such a good deal?

15EUR/month on http://lost-oasis.fr i write about them because they make a lot
of contributions to open-source...


[e:\]ping lost-oasis.fr

Pinging lost-oasis.fr [80.67.180.4] with 32 bytes of data:

Request timed out.
Request timed out.
Request timed out.
Request timed out.

Ping statistics for 80.67.180.4:
Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),
Ahem ....

--Irmen

Jul 18 '05 #16
Fazer wrote:
I personally find it much easier to learn about system administration
and get my own dedicated server for EUR 39/month.


39? Where do you get such a good deal?


http://hetzner.de/ - "Entry Server" EUR 39
http://www.server4free.de/ - EUR 30
http://www.server4free.de/ - VServer (basically User Mode Linux) - EUR 10

http://www.1und1.com/ - EUR 49

These are the cheapest offers of the relevant German providers. They all
come with a considerable setup fee as well, so don't just look at the
monthly fee.

-- Gerhard

Jul 18 '05 #17
Gerhard Häring <gh@ghaering.de> writes:
I personally find it much easier to learn about system
administration and get my own dedicated server for EUR 39/month.

39? Where do you get such a good deal?


http://hetzner.de/ - "Entry Server" EUR 39
http://www.server4free.de/ - EUR 30
http://www.server4free.de/ - VServer (basically User Mode Linux) - EUR 10

http://www.1und1.com/ - EUR 49

These are the cheapest offers of the relevant German providers. They
all come with a considerable setup fee as well, so don't just look at
the monthly fee.


www.usermodelinux.org has links to a bunch of other such providers.
EUR 10 is the lowest monthly price I've seen, but I think there are
some in the 20 USD/month range with low or no setup fees.
Jul 18 '05 #18

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Roy Smith | last post by:
I'm working on a prototype of a new application in Python. At some point, if this ever turns into a product, the powers that be will almost certainly demand that it be done in Perl. My job will...
42
by: Fred Ma | last post by:
Hello, This is not a troll posting, and I've refrained from asking because I've seen similar threads get all nitter-nattery. But I really want to make a decision on how best to invest my time....
46
by: Reinhold Birkenfeld | last post by:
Hello, another Perl/Python question: the subject says it all. Perl is going to change dramatically to become a more powerful and easier to (read|write) language. Is Python taking a similar...
31
by: surfunbear | last post by:
I've read some posts on Perl versus Python and studied a bit of my Python book. I'm a software engineer, familiar with C++ objected oriented development, but have been using Perl because it is...
68
by: Lad | last post by:
Is anyone capable of providing Python advantages over PHP if there are any? Cheers, L.
9
by: Dieter Vanderelst | last post by:
Dear all, I'm currently comparing Python versus Perl to use in a project that involved a lot of text processing. I'm trying to determine what the most efficient language would be for our...
13
by: squash | last post by:
I am a little annoyed at why such a simple program in Perl is causing so much difficulty for python, i.e: $a += 200000 * 140000; print $a;
12
by: rurpy | last post by:
Is there an effcient way (more so than cgi) of using Python with Microsoft IIS? Something equivalent to Perl-ISAPI?
21
by: Roy Smith | last post by:
I'm working on a product which for a long time has had a Perl binding for our remote access API. A while ago, I wrote a Python binding on my own, chatted it up a bit internally, and recently had a...
8
by: Palindrom | last post by:
Hi everyone ! I'd like to apologize in advance for my bad english, it's not my mother tongue... My girlfriend (who is a newbie in Python, but knows Perl quite well) asked me this morning why...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
1
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
2
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...
1
by: Johno34 | last post by:
I have this click event on my form. It speaks to a Datasheet Subform Private Sub Command260_Click() Dim r As DAO.Recordset Set r = Form_frmABCD.Form.RecordsetClone r.MoveFirst Do If...
1
by: ezappsrUS | last post by:
Hi, I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox being checked or not. Below is the...
0
DizelArs
by: DizelArs | last post by:
Hi all) Faced with a problem, element.click() event doesn't work in Safari browser. Tried various tricks like emulating touch event through a function: let clickEvent = new Event('click', {...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.