python2.5. faster startup, better memory use, faster.

Recently I was testing that pygame still works with the python2.5 beta. When I was doing this, I had a chance to play around with python2.5 and all it's new goodness. Amongst the other good python2.5 features is that python is performing better.

Almost twice as fast a startup 'cold'.

This is because it uses half the number of syscalls as python2.4 does. 755 syscalls in 2.4 and 461 in 2.5. Still not quite as good as perl with 40ish syscalls, but a massive improvement none the less.

$ time python2.4 -c "print 'hello'"

real 0m0.923s
user 0m0.041s
sys 0m0.025s

$ time python2.5 -c "print 'hello'"

real 0m0.417s
user 0m0.043s
sys 0m0.021s

However compared to perl, python is still syscall heavy. Perl does around 50ish syscalls to start up.

Python2.5 also frees up more memory that it isn't using.

Python2.4 does not release all that much memory if you use up quite a lot. It holds onto it in it's memory pool as an optimisation. The idea is that it is quicker to reuse memory, than to rely on the operating systems memory management. Unfortunately, this can be *really* bad for long running processes, and on machines which need to share with other processes. ie webservers, games, gui apps.

Even though there could still be improvements, my tests with real world applications using 2.5 show a much better use of memory. It gives back most of what is used. However for best use of memory it is still a good idea to restart processes if you can.


Kunal said…
This is all great stuff. A smaller footprint is always better.
saluk said…
Python just keeps getting better and better!

On an unrelated note, what happened to and pycal3d?
illume said… was based on plone. At some point plone stopped working, and I couldn't get it going again. Luckily there is another big list of python 3d projects, and some of the articles/wiki pages are in internet archives.

pycal3d hasn't been touched by me for a while. I have a 60% complete C replacement written. It has very few features, pretty much just enough to animate milkshape 3d models. However I haven't had a need for animated 3d models, so it's in the big pile of unfinished projects.

What a slack arse I am.

Popular posts from this blog

Is PostgreSQL good enough?

Hey! It's work on pygame stuff week.

pygame on pypy usable