[PYTHON DB-SIG] Python vs Perl DB API
Wed, 05 Feb 1997 22:02:35 +0100
> 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').
I don't think that it is in the oracledb module.
Python tends to be about 2-3 times slower than
Persuade Everybody Really Leaveit
because there are lots of possible optimizations in Python which
will come in one or two versions.
It also depends very much on what you do with Python.
It is generally not efficient to do few things in small inner loops.
> 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??
It depends how you have done it. The printing stuff can be extremely
efficient, if you assemble larger parts, and do not glue pieces
together but use the % operator.
You might show me the code, and I will see where time is wasted.
Python also has a profiler, which might point you to the few
lines which make up 90% of the time.
> Happy for ANY answer.
welcome - chris
DB-SIG - SIG on Tabular Databases in Python
send messages to: email@example.com
administrivia to: firstname.lastname@example.org