Page 1 of 2 12 Last
  • Jump to page:
    #1
  1. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2003
    Location
    Canada
    Posts
    543
    Rep Power
    24

    Trusting that snake


    Some people have told me that Python is very slow. This has scared me. I love Python. Personally, I think that it's the best language.

    I wanted to start a big project. I wanted to make my own forum. Can I trust Python to be able to be fast enough?
  2. #2
  3. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    Yes!!!! Pythons fast enough for nearly all business applications and even then you can replace slow bits it with C/C++ and watch it burn!

    Really dont worry about it Chief, the page will - usually - be created by the server and waiting for the visitors browser to load it well in advance!

    Now, if you are really worried about prefomance you should look into mod_python

    http://www.modpython.org/
    http://www.onlamp.com/pub/a/python/2...od_python.html

    Long time no see, hope everythings well with you!

    Mark.
    programming language development: www.netytan.com Hula

  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2003
    Location
    Canada
    Posts
    543
    Rep Power
    24
    I now have mod_python.

    How do I execute my Python scripts anywhere on my Apache Web server?

    Lets use the following as our test script:

    Code:
    #!/usr/bin/env python
    
    import sys, time
    
    state = 0
    
    def twist(symbols):
    	global state
    	sys.stdout.write(symbols[state] + '\r')
    	if state == len(symbols) - 1:
    		state = -1
    	state = state + 1
    	
    if __name__ == '__main__':
    	
    	while True:
    		twist(('|', '/', '-', '\'))
    		time.sleep(1)
    netytan: You wrote this script. I found it here

    I hope you don't mind. I will remove it if you would like and use a different test script.
    Last edited by MasterChief; January 28th, 2004 at 11:08 PM.
  6. #4
  7. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    Naw i don't mind one bit chief, you're welcome to use any of the code i've writen, smash it, rewrite whatever

    saddly due to the nature of http this script aint gonna work for you since browers cant remove content once it's been displayed like in consols.

    What versions of mod_python/python/handler are you using? I think the latest or next version is going to includes PSP so that could be fun!

    Edit: Now that i think about it it might be worth using the beta version with PSP and putting up with any little bugs untill the final release is done; that way you're app will be one of the first to use "true" PSP, which is a nice little side heading . Also, if you email me i might have a little treat for you!

    Mark.
    Last edited by netytan; January 29th, 2004 at 06:58 AM.
    programming language development: www.netytan.com Hula

  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2003
    Location
    Canada
    Posts
    543
    Rep Power
    24
    I have 3.0.4. I'll get the latest version with PSP. What is that, by the way?
  10. #6
  11. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    PSP or Python Server Pages are a way of embedding Python in HTML similar to the way PHP or ASP does it. There are a few different systems around but none are gonna be as fast as mod_pythons PSP handler so

    http://www.modpython.org/live/mod_py.../hand-psp.html

    If not you can always write you're own handler. the CGI hander is pretty nice though, its pretty much fastCGI.. which reminds me i should really install that

    Mark.
    programming language development: www.netytan.com Hula

  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2003
    Location
    Canada
    Posts
    543
    Rep Power
    24
    Horrah! It works!

    If you're interested in looking at the working test-file, go here.

    It just says "Hello World!"

    Note how fast it loads/executes!
    Last edited by MasterChief; January 29th, 2004 at 08:59 AM.
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2003
    Location
    Canada
    Posts
    543
    Rep Power
    24
    I either don't have PSP, I don't have it enabled, or it's just not working.

    I have mod_python 3.1.2b (Win32)
  16. #9
  17. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    Cute . you got broad band then? Anyway i'm still trying to get PSP working myself, seems to be broken, or at least in the windows version.

    Edit: Ah, cant get this working at all, it just ignores the tags so i'm gonna stick with mod_pythons CGI handler for now.

    Mark.
    Last edited by netytan; January 29th, 2004 at 08:10 AM.
    programming language development: www.netytan.com Hula

  18. #10
  19. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2003
    Location
    Canada
    Posts
    543
    Rep Power
    24
    How come all of my test files are saying "Hello World!"? Only mptest.py is supposed to do that.
  20. #11
  21. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    Ah you created you're own handler that outputs 'Hello World!' heh. you apache config should look like this if you want to use Python CCI.

    <Directory X:/XXXXX/htdocs/>
    AddHandler python-program .py
    PythonHandler mod_python.cgihandler
    PythonDebug On
    </Directory>
    Then just write CGi programs as normal. The publisher handler is just nuts and gets on my nerves so

    Note: set the directory yourself. i dont know where you have apacje installed so.

    Mark.
    programming language development: www.netytan.com Hula

  22. #12
  23. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2003
    Location
    Canada
    Posts
    543
    Rep Power
    24
    I'm just getting blank screens...

    I added:

    <Directory "C:/Documents and Settings/Spencer/My Documents/Apache2/htdocs/">
    AddHandler python-program .py
    PythonHandler mod_python.cgihandler
    PythonDebug On
    </Directory>

    to my httpd file. Do I save the files as .py (like I'm doing now) or .cgi?
  24. #13
  25. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    Yeah you save it with a .py file and write the CGI file as normal i.e.

    Code:
    #!/usr/bin/env python
    
    print 'Content-Type: text/html\n'
    print 'Hello World!'
    Mark.
    programming language development: www.netytan.com Hula

  26. #14
  27. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2003
    Location
    Canada
    Posts
    543
    Rep Power
    24
    All right, it works. You can view it here.

    You rock!
  28. #15
  29. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    no problem Chief, liked the link ! Oh, i'm writing a module you might be interested in being as you're writing a web application!

    Mark.
    programming language development: www.netytan.com Hula

Page 1 of 2 12 Last
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo