Improved performance of Python 3.1

Posted August 21st @ 3:41 pm by admin

In my previous post (six months ago) I claim about the bad performance of Python 3.0. The first py3k version contained a new I/O library written totally in python that was the main cause of such problems.

Now Python 3.1 present a totally new I/O Library rewritten in c for maximum performance. As promised, I re-execute all my previus tests with the latest python version (3.1.1).

The next graph show the results, look at my previous post for details on the tests.

Different python version compared for performance

Different python version compared for performance

Text Read/Write

First you can see that the incredible bad text read issue is now solved. Python 3.1 is now much much faster, but it remain 2.42x slower than python 2.5. This is probably due to the text decoding phase. Text writing is now comparable to python 2.5.

Binary Read/Write

The rewritten I/O module is now able to read binary data faster than before. The same is not true for the writing performance that remain slow as Python 3.0.

Print

Another problem that I noticed in python 3.0 was the very bad performance on the new print function compared to the old print statement. In this test, Python 3.1 is now “only” 5 times slower than Python 2.5.

In general a good work was done to optimize py3k. I think that for general applications, py3k is now perfectly usable.

Many thanks to the python development team!

2 Comments

  1. haypo
    August 24, 2009 at 22:20

    Can you post the source code of the benchmark to reproduce the test on my computer? What is the exact Python versions, the OS and the CPU?

  2. admin
    August 25, 2009 at 08:52

    The source of each test is visible here: http://www.gtsystem.eu/blog/2009/08/improved-performance-of-python-31/2008/12/python-30-io-performance-issues/

    The python versions are: Python 2.5.2, Python 3.0, Python 3.1.1
    MacBook Pro 2,4 Ghz running Mac OS X 10.5.7

Sorry, comments for this entry are closed at this time.

Options:

Size

Colors