Python vs. Perl vs. PHP?

Discussion in 'Python' started by Fazer, Jul 28, 2003.

  1. Fazer

    Fazer Guest

    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?
    Fazer, Jul 28, 2003
    #1
    1. Advertising

  2. Fazer

    Wilk Guest

    (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
    Wilk, Jul 28, 2003
    #2
    1. Advertising

  3. 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
    Diez B. Roggisch, Jul 28, 2003
    #3
  4. Fazer

    Wilk Guest

    "Diez B. Roggisch" <> 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
    Wilk, Jul 28, 2003
    #4
  5. Fazer

    Fazer Guest

    "Diez B. Roggisch" <> wrote in message news:<bg3qkk$lmr$05$-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.
    Fazer, Jul 29, 2003
    #5
  6. Fazer

    Fazer Guest

    Nevermind. I RTFM :) .
    Fazer, Jul 29, 2003
    #6
  7. Fazer

    Aahz Guest

    In article <>,
    Fazer <> 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 () <*> http://www.pythoncraft.com/

    This is Python. We don't care much about theory, except where it intersects
    with useful practice. --Aahz
    Aahz, Jul 29, 2003
    #7
  8. Fazer

    Graham Breed Guest

    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
    Graham Breed, Jul 30, 2003
    #8
  9. 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
    =?ISO-8859-1?Q?Gerhard_H=E4ring?=, Jul 31, 2003
    #9
  10. Fazer

    Fazer Guest

    Gerhard Häring <> wrote in message news:<>...
    > 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.
    Fazer, Jul 31, 2003
    #10
  11. 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
    =?ISO-8859-1?Q?Gerhard_H=E4ring?=, Aug 1, 2003
    #11
  12. 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
    Diez B. Roggisch, Aug 1, 2003
    #12
  13. >> 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
    Diez B. Roggisch, Aug 1, 2003
    #13
  14. Fazer

    Fazer Guest

    > 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?
    Fazer, Aug 3, 2003
    #14
  15. Fazer

    Wilk Guest

    (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
    Wilk, Aug 3, 2003
    #15
  16. Wilk wrote:

    > (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
    Irmen de Jong, Aug 3, 2003
    #16
  17. 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
    =?ISO-8859-1?Q?Gerhard_H=E4ring?=, Aug 4, 2003
    #17
  18. Fazer

    Paul Rubin Guest

    Gerhard Häring <> 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.
    Paul Rubin, Aug 4, 2003
    #18
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ted Zeng
    Replies:
    4
    Views:
    471
    Tim Arnold
    Oct 3, 2006
  2. Ted Zeng
    Replies:
    0
    Views:
    600
    Ted Zeng
    Oct 13, 2006
  3. Rajive Narain
    Replies:
    0
    Views:
    1,487
    Rajive Narain
    Sep 18, 2009
  4. Ignoramus6539
    Replies:
    2
    Views:
    193
    Colin McKinnon
    Aug 30, 2006
  5. M. Strobel
    Replies:
    1
    Views:
    196
    The Natural Philosopher
    Mar 5, 2013
Loading...

Share This Page