[XML-SIG] XML package speed (or lack thereof...)?

skip@mojam.com (Skip Montanaro) skip@mojam.com (Skip Montanaro)
Tue, 27 Apr 1999 13:23:13 -0400


I'm using XML-RPC to provide an over-the-net API to Python, Perl and Java
clients on my server.  I'm currently using a hacked up version of Fredrik
Lundh's xmlrpclib module.  The hacking part involved writing a C module to
do the low-level encoding and decoding so it was fast enough for my
purposes.  This library only does XML-RPC, nothing else.

Ideally, I'd like to dump my XML-RPC-specific code in favor of something
more general, robust and better supported.  Accordingly, I downloaded the
0.5.1 version of the xml-sig package today and gave it a whirl.  After
making a couple small mods to marshal/generic/test:

    def test(load, loads, dump, dumps, test_values,
	     do_assert = 1):
	# Try all the above bits of data
	try: from cStringIO import StringIO
	except ImportError: from StringIO import StringIO
	import time

	t = time.time()
	for i in range(10):
	    for item in test_values:
		s = dumps(item)
		#print item, s
		output = loads(s)
		# Try it from a file
		file = StringIO()
		dump(item, file)
		file.seek(0)
		output2 = load(file)

		if do_assert:
		    assert item==output and item==output2 and output==output2
	t = time.time() - t
	print "total time: %.2f seconds" % t
	print "time per pass: %.2f seconds" % (t/10)

and commenting out a print statement in marshal/xmlrpc/XMLRPCUnmarshaller/
um_end_dictionary, I was able to run the test without any spurious messages.
I got the following output on my 100 MHz Pentium (Python 1.5.1, RH Linux
5.0):

    >>> xml.marshal.xmlrpc.runtests ()
    Testing XML-RPC marshalling...
    total time: 9.77 seconds
    time per pass: 0.98 seconds

This is hardly what I would call blazing speed (perhaps 30-100x slower than
what I currently get), especially considering the small size of the test
data, so I thought perhaps I was missing something - an optional C library
perhaps?  I see that Fredrik's sgmlop module was built and installed, but my
guess is that it's not being used.

Thx,

Skip Montanaro	| Mojam: "Uniting the World of Music" http://www.mojam.com/
skip@mojam.com  | Musi-Cal: http://www.musi-cal.com/
518-372-5583