[PYTHON DB-SIG] Python vs Perl DB API
aaron watters
aaron_watters@msn.com
Wed, 5 Feb 97 23:27:22 UT
Without the code it's hard to say, but I'd assume there may be some
room for improvement in your code, as I haven't seen it :).
One thing you should do right away is, if you are doing everything
at a global level, try just enclosing the whole thing in a function.
This can get a 2x speedup when lots of variable references are made
-- and it's even faster if you forget to execute the function!
There are lots of ways to format text poorly in Python. At the risk
of chastisement ;) I'd suggest that some sections (Playing and Generating
HTML) which I wrote in Internet Programming with Python (book)
describe text formatting in detail - although blinding speed isn't always
the focus. Maybe try formatting the data in larger chunks (using
s % tuple and string.joinfields etc) and writing directly to sys.stdout.
In my oracle grub days I used to load 100000 tuples
(lst=curs.fetchmany(100000)) at once, l = map(fmter, lst) mapping a
formatter function across them and slam them out to a file using
sys.stdout.write(string.joinfields(l, "\n")). I thought this screamed.
In general I don't think Python 1.4 properly used is significantly slower than
Perl,
but in the special case of simple text formatting Perl probably is faster --
after all that's what it was designed to do originally. - Aaron Watters
----------
From: owner-db-sig@python.org on behalf of Orjan Reinholdsen
Sent: Wednesday, February 05, 1997 12:47 PM
To: db-sig@python.org
Subject: [PYTHON DB-SIG] Python vs Perl DB API
Hello!
Lately, I'v left Perl behind and I'm now using Python (and
'oracledb') to interface our Oracle DB. Generally this works great
and I really adore the Python syntax compared to Perl, but now I'v
run into some questions regarding speed:
I'v timed the execution of a Perl script and a Python script
doing the same thing, with the result that the Perl script is
roughly 3 times faster that the Python script. I should note that the
DB operations in the scripts involves a select and the formating
of roughly 2500 lines of text output (mainly using 'print').
So the question arise: Why is the Python script significantly slower
than the Perl script? Is it because of the "speed" of 'oracledb'
and/or the Python DB API, or is it because Python is generically
slower that Perl? Any suggestions for speed improvement??
Happy for ANY answer.
Regards,
Orjan Reinholdsen
==============================================================================
==
Orjan Reinholdsen Infopartners SA
Voice: +352 29 57 59 33 02 Fax: +352 29 57 59 39
00
e-mail: orjan@ip.lu
==============================================================================
==
_______________
DB-SIG - SIG on Tabular Databases in Python
send messages to: db-sig@python.org
administrivia to: db-sig-request@python.org
_______________
_______________
DB-SIG - SIG on Tabular Databases in Python
send messages to: db-sig@python.org
administrivia to: db-sig-request@python.org
_______________