Is there a speed difference between python2.7 + mysqldb and python3.1 and myconnpy?

Asked by tormen

Hi Geert,

I am not sure where to post this, so I post it as a question, even
though it is more an answer ;)

We have a python3 based API with mysql backend using myconnpy...

And now we ported this to python2.7 (which was actually not that hard) and adapted our db-routines to mysqldb 1.2.3 (same functionality, same complexity of code, just mostly different syntax...).

Which enabled us to do a direct real life speed comparison :)

In a nutshell: python 3.1 with myconnpy yields the SAME speed than python 2.7 with mysqldb!

So if you can even optimize more we might end up getting even FASTER then mysqldb ;>

Here are the results:

Test: Select, modify, save one ~26k record 100 times.
Python 2.7 Server:
real 2m37.317s
user 0m0.450s
sys 0m0.120s

Python 3.1 Server:
real 2m33.375s
user 0m0.370s
sys 0m0.200s

Test: Select ~200 rows of ~200 bytes in length from one table, and
insert them into another table.
PYTHON 2.7 Server:
$ time python3.1 test4.py

real 0m4.354s
user 0m0.196s
sys 0m0.036s

$ time python3.1 test4.py

real 0m4.373s
user 0m0.196s
sys 0m0.048s

PYTHON 3.1 Server:
$ time python3.1 test4.py

real 0m4.400s
user 0m0.204s
sys 0m0.036s

$ time python3.1 test4.py

real 0m4.419s
user 0m0.200s
sys 0m0.040s

Test: Select ~1000 rows of ~25k bytes in length.
Python 2.7 Server:
$ time python3.1 test5.py
Got 1045 log-entries...

real 0m14.153s
user 0m7.512s
sys 0m0.416s

$ time python3.1 test5.py
Got 1045 log-entries...

real 0m13.987s
user 0m7.480s
sys 0m0.416s

Python 3.1 Server:
$ time python3.1 test5.py
Got 1045 log-entries...

real 0m14.116s
user 0m7.284s
sys 0m0.404s

$ time python3.1 test5.py
Got 1045 log-entries...

real 0m15.286s
user 0m7.832s
sys 0m0.452s

Cheers,

Knuth

Question information

Language:
English Edit question
Status:
Open
For:
MySQL Connector/Python Edit question
Assignee:
Geert JM Vanderkelen Edit question
Last query:
Last reply:
Revision history for this message
Geert JM Vanderkelen (geertjmvdk) said :
#1

Hi!

Sorry, indeed busy (baby, work, and.. hehe :))
Thanks for comparing and benchmarking a bit. It's quite nice to see folks doing this with own applications.

Anyway, I've been doing some stuff in between with how packets are received. Fixing bugs, refactoring, and, most importantly, optimizing code for Python 3.1.
The code now publicly should actually be slow when used with Python 3..

Anyway, stay tuned..

Cheers,
Geert

Revision history for this message
Geert JM Vanderkelen (geertjmvdk) said :
#2

It would be good to retest with MySQL Connector/Python v0.3. We're using memoryviews and such to make the code (hopefully) faster.

Can you help with this problem?

Provide an answer of your own, or ask tormen for more information if necessary.

To post a message you must log in.