|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
AT&T devCentral & BlackBerry(r) Webcast Series: BlackBerry and GPS -Build Location Awareness into your BlackBerry Applications, July 10th-1:00PM EST. Register Today!
|
|
#1
|
|||
|
|||
|
xml-rpc
Hi,
Newbie here. This is a python question, not a php question. I have demo code that came with phprpc library: xml-rpc client in python xml-rpc client in php xml-rpc server in php _ with php server and python client both on local machine: runs fine with php server and python client both on remote machine runs fine with _local php client and remote php server: runs fine But, with local python client and remote php server: runs too slowly to be usable. Just curious about what issues (in general) are involved here. Thanks, Walt |
|
#2
|
|||
|
|||
|
No replies huh.
I really am curious about whethor or not Python can be quick enough to use for locally executed xml-rpc clients. Looks like it can't. So, I tried the equivalent Perl code and it executes much faster than the Python script(which is pasted below). I'm running these scripts under Linux on a 400 Mhz machine with plenty of ram. The Python version loads and executes in about 28 seconds. The Perl version takes about 7 seconds I'm thinking it would be nice to use Python both client-side and server-side. But slow execution on the client might make that a bad idea. Code:
#!/usr/local/bin/python
from xmlrpclib import *
import sys
server = Server("http://wmich.freeshell.org/betty.php")
try:
print "Got '" + server.examples.getStateName(32) + "'"
print "----------------------------------------------------"
r = server.examples.echo('Three "blind" mice - ' + "See 'how' they run")
print r
print "--------------------------------------------"
# name/age example. this exercises structs and arrays
a = [ {'name': 'Dave', 'age': 35}, {'name': 'Edd', 'age': 45 },
{'name': 'Fred', 'age': 23}, {'name': 'Barney', 'age': 36 }]
r = server.examples.sortByAge(a)
print r
print "---------------------------------------------"
except Error, v:
print "XML-RPC Error:",v
|
|
#3
|
||||
|
||||
|
Way, lil testy arnt we
... this really is NOT Pythons fault at all... actually this one seems to be purly programmer error ... with a little reworking your client works perfectly, a little under 4 seconds on my machine compared to your 7 seconds of perl!Code:
#!/usr/local/bin/python
import xmlrpclib, sys
server = xmlrpclib.Server("http://wmich.freeshell.org/betty.php")
a = [{'name': 'Dave', 'age': 35}, {'name': 'Edd', 'age': 45},
{'name': 'Fred', 'age': 23}, {'name': 'Barney', 'age': 36}]
try:
print "Got '%s'" % server.examples.getStateName(32)
print "---------------------------------------------"
print server.examples.echo("Three \"blind\" mice - See 'how' they run")
print "---------------------------------------------"
print server.examples.sortByAge(a)
print "---------------------------------------------"
except Exception, message:
print "XML-RPC Error:", message
Anyway, Python is a great choice for both server and client program! Give it a go ![]() Mark. Last edited by netytan : December 26th, 2003 at 12:35 PM. |
|
#4
|
|||
|
|||
|
Not tresty at all. Second post was just to give more info in hope of getting a reply like yours.
Thanks, I really appreciate it. Walt |
|
#5
|
||||
|
||||
|
Any time walt
, you got the thing working now or what?Mark. |
|
#6
|
|||
|
|||
|
yes.
I've now booted into windows, and both versions are pretty quick. Can't tell which one is faster. I'll have to learn how to add a timer function. Didn't write any code myself, just running an example program to get a feel for Python. Have been messing with PythonCard and think it's cool. Heve been able to package scripts into windows executables and think thats cool too. My dilemma was that execution under my Linux setup was really slow. Thanks again, Walt |
|
#7
|
|||
|
|||
|
I just cut and pasted both of these scripts into PythonWin and ran them a couple of time (with the small addition of an import time and the clock function to test them). Both of them run at less then 4 seconds a script. (Less then three seconds being the normal). I don't think those couple of concat could have made that big of a difference (20 some seconds?). Your thoughts netytan?
Though with this script, your calling over the network, I can't see the script being the main source of delay. |
|
#8
|
||||
|
||||
|
Mmmm, how very strange. When i first ran walts client it took at least 20 seconds to execute, i then rewrote it and the new client it ran in a little over 3 seconds according to timeit
so I posted the code above ![]() Now I ran walts again and it worked fine. I've also ran the two against eachother to compare times, heres what i got if anyones interested.. client1 - 3.29521098352 client2 - 3.08644506495 No idea why it took so long to run the first few times then cleared up compleatly ![]() The only thing i can think of is that because i've never imported xmlrpclib before Python had to compile the code; but that would mean that the "from module import" statment doesn't compile the module like "import" does which is total **** since i know it does! No idea, it works now so i'm not gonna over analyse, but i would like to know why ![]() Mark. |
|
#9
|
|||
|
|||
|
Time to put this thread to bed.
Have just executed these scripts on an old, under-powered, over-burdened Pentium I, and they ran fine. I'm satisfied that Python is not a dog. There's probably a networking issue on my faster machine. Thanks for looking into it for me. Walt |
|
#10
|
|||
|
|||
|
Hey!
It's the python version that's causing trouble. "python2.1 askbetty.py" takes about 5 seconds. But, "python2.3 askbetty.py" takes about 85 seconds on the same machine. This is my old P133 box. Bummer |
|
#11
|
|||
|
|||
|
Quote:
Can you post the exact script you used here? I've got 2.3 installed on my laptop and I'd like to take a look at it. |
|
#12
|
|||
|
|||
|
Yes. It's posted above.
|
|
#13
|
|||
|
|||
|
Just tried Netytan's version.
python 2.1 = 5 seconds python2.3 = 60 seconds |
|
#14
|
|||
|
|||
|
Wow, a P1 must be way slower than I think. My Athlon 1.5XP runs the script in about 3 seconds (Python 2.3), as shown by running "time script.py". I tried about 20 times.
Where is the biggest delay occuring (after which print statement)? You could have a look at the Python profiler: http://www.python.org/doc/current/lib/profile.html. Also, give this a read: http://manatee.mojam.com/~skip/python/fastpython.html. If you have two versions of Python installed on your machine, 2.3 _might_ be using the site-packages folder (and the xmlrpclib) from 2.1 inadvertantly (I've had this happen on at least one occasion). How are you running it for 2.1 vs. 2.3? Are you changing the shebang line? Maybe try removing it, just to see? What does /usr/local/bin/python point to (2.1 or 2.3)? |
|
#15
|
|||
|
|||
|
have downloaded the latest xmlrpclib version 1.0.1
Brief sample code is included at the end of the file. It calls a procedure at betty,userland.com. When I invoke it this way: "python2.3 xmlrpclib.py" execution takes about 20 seconds. When I invoke it this way: "python2.1 xmlrpclib.py" execution takes about 1 second. python2.1 and python2.3 executables are both located in /usr/bin Last edited by wmich : December 28th, 2003 at 12:38 PM. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Python Programming > xml-rpc |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
| < |