Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old January 28th, 2004, 01:57 AM
MasterChief MasterChief is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Location: Virginia
Posts: 491 MasterChief User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 47 m 47 sec
Reputation Power: 6
Send a message via AIM to MasterChief Send a message via MSN to MasterChief
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?

Reply With Quote
  #2  
Old January 28th, 2004, 03:17 AM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,529 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 17 h 19 m 5 sec
Reputation Power: 63
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
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/...mod_python.html

Long time no see, hope everythings well with you!

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


Reply With Quote
  #3  
Old January 28th, 2004, 11:02 PM
MasterChief MasterChief is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Location: Virginia
Posts: 491 MasterChief User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 47 m 47 sec
Reputation Power: 6
Send a message via AIM to MasterChief Send a message via MSN to MasterChief
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.

Reply With Quote
  #4  
Old January 29th, 2004, 06:46 AM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,529 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 17 h 19 m 5 sec
Reputation Power: 63
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
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.

Reply With Quote
  #5  
Old January 29th, 2004, 07:02 AM
MasterChief MasterChief is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Location: Virginia
Posts: 491 MasterChief User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 47 m 47 sec
Reputation Power: 6
Send a message via AIM to MasterChief Send a message via MSN to MasterChief
I have 3.0.4. I'll get the latest version with PSP. What is that, by the way?

Reply With Quote
  #6  
Old January 29th, 2004, 07:24 AM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,529 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 17 h 19 m 5 sec
Reputation Power: 63
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
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_p...l/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.

Reply With Quote
  #7  
Old January 29th, 2004, 07:50 AM
MasterChief MasterChief is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Location: Virginia
Posts: 491 MasterChief User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 47 m 47 sec
Reputation Power: 6
Send a message via AIM to MasterChief Send a message via MSN to MasterChief
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.

Reply With Quote
  #8  
Old January 29th, 2004, 08:00 AM
MasterChief MasterChief is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Location: Virginia
Posts: 491 MasterChief User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 47 m 47 sec
Reputation Power: 6
Send a message via AIM to MasterChief Send a message via MSN to MasterChief
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)

Reply With Quote
  #9  
Old January 29th, 2004, 08:07 AM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,529 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 17 h 19 m 5 sec
Reputation Power: 63
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
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.

Reply With Quote
  #10  
Old January 29th, 2004, 08:16 AM
MasterChief MasterChief is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Location: Virginia
Posts: 491 MasterChief User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 47 m 47 sec
Reputation Power: 6
Send a message via AIM to MasterChief Send a message via MSN to MasterChief
How come all of my test files are saying "Hello World!"? Only mptest.py is supposed to do that.

Reply With Quote
  #11  
Old January 29th, 2004, 08:21 AM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,529 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 17 h 19 m 5 sec
Reputation Power: 63
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
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.

Quote:
<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.

Reply With Quote
  #12  
Old January 29th, 2004, 08:33 AM
MasterChief MasterChief is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Location: Virginia
Posts: 491 MasterChief User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 47 m 47 sec
Reputation Power: 6
Send a message via AIM to MasterChief Send a message via MSN to MasterChief
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?

Reply With Quote
  #13  
Old January 29th, 2004, 08:49 AM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,529 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 17 h 19 m 5 sec
Reputation Power: 63
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
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.

Reply With Quote
  #14  
Old January 29th, 2004, 09:02 AM
MasterChief MasterChief is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Location: Virginia
Posts: 491 MasterChief User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 47 m 47 sec
Reputation Power: 6
Send a message via AIM to MasterChief Send a message via MSN to MasterChief
All right, it works. You can view it here.

You rock!