SunQuest
           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:
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  
Old December 25th, 2003, 10:58 AM
wmich wmich is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2001
Posts: 9 wmich User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
  #2  
Old December 26th, 2003, 11:25 AM
wmich wmich is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2001
Posts: 9 wmich User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
  #3  
Old December 26th, 2003, 12:18 PM
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
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.
__________________
programming language development: www.netytan.com Hula


Last edited by netytan : December 26th, 2003 at 12:35 PM.

Reply With Quote
  #4  
Old December 26th, 2003, 12:54 PM
wmich wmich is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2001
Posts: 9 wmich User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
  #5  
Old December 26th, 2003, 12:58 PM
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
Any time walt , you got the thing working now or what?

Mark.

Reply With Quote
  #6  
Old December 26th, 2003, 01:43 PM
wmich wmich is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2001
Posts: 9 wmich User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
  #7  
Old December 26th, 2003, 03:22 PM
ragabash ragabash is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: Yuma,AZ
Posts: 11 ragabash User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to ragabash Send a message via Yahoo to ragabash
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.

Reply With Quote
  #8  
Old December 26th, 2003, 03:49 PM
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
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.

Reply With Quote
  #9  
Old December 26th, 2003, 05:20 PM
wmich wmich is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2001
Posts: 9 wmich User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
  #10  
Old December 28th, 2003, 12:01 AM
wmich wmich is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2001
Posts: 9 wmich User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
  #11  
Old December 28th, 2003, 09:48 AM
oxygenthief oxygenthief is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 35 oxygenthief User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
Quote:
Originally posted by wmich
But, "python2.3 askbetty.py" takes about 85 seconds on the same machine.


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.

Reply With Quote
  #12  
Old December 28th, 2003, 10:10 AM
wmich wmich is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2001
Posts: 9 wmich User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Yes. It's posted above.

Reply With Quote
  #13  
Old December 28th, 2003, 10:25 AM
wmich wmich is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2001
Posts: 9 wmich User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Just tried Netytan's version.

python 2.1 = 5 seconds
python2.3 = 60 seconds

Reply With Quote
  #14  
Old December 28th, 2003, 11:52 AM
oxygenthief oxygenthief is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 35 oxygenthief User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
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)?

Reply With Quote
  #15  
Old December 28th, 2003, 12:25 PM
wmich wmich is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2001
Posts: 9 wmich User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > xml-rpc


<
Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread