2

I'm working on an open source project (Master of Mana, a mod for Civilization 4) which uses Python 2.4.1 for several game mechanics. Is there a chance for a performance improvement if I try to upgrade to Python 2.7.3 or even 3.3.0?

Related to this, has anyone done a performance analysis on different Python versions?

André
  • 189
  • 3
  • 14
  • This might help you http://stackoverflow.com/questions/7083961/python-versions-performance – Dominik G Jan 11 '13 at 15:33
  • It's hard to give a good answer to this without more information. Every version of Python is faster or slower than every other version, depending on what you do and how you do it. So I guess in a literal sense, the answer to your question is "yes, there is a chance of a performance improvement if you try to upgrade to Python 2.7.3 or even 3.3.0". – John Y Jan 11 '13 at 15:35
  • You might get better answers if you accept answers to your former questions. If none of them solved your question, write how you did it and accept your own answer. – glglgl Jan 11 '13 at 15:37
  • related: http://stackoverflow.com/questions/11400472/list-indexing-efficiency-python-2-vs-python-3 although this question deals with a much more restricted measurement. – mgilson Jan 11 '13 at 15:51
  • From my experience on the switch from Python 2.7 to Python 3.0 (that’s the one I did back then), Python 2 seems to do some basic operations slightly faster than Python 3. That “faster” would usually fall into “premature optimization” though and probably won’t be your bottleneck unless you do really heavy computational stuff. That being said, Python 3.1 and 3.2 further improved the speed a lot, so that the difference between 2.7 and 3.3 is probably not much. But of course, you don’t do the Python 3 switch for performance but for the many other improvements. – poke Jan 11 '13 at 16:06
  • Don't expect a magic bullet here. Normally bad written code is responsible for way more cpu cycles than some language implementation details. That's why these language X is faster than language Y flamewars are mostly irrelevant. – RickyA Jan 11 '13 at 16:12
  • The classic way to speed up a Python program is still to write hot code in C. So I don't think there's any groundbreaking performance in the last few year. Python 2.4 is ancient though. – Kien Truong Jan 11 '13 at 16:22
  • Ok, so I won't try to upgrade the Python version. Thanks for your ideas. :) – André Jan 12 '13 at 08:45

1 Answers1

0

Most newer Python versions bring new features.

Existing code parts are probably updated as well, either for performance or for extended functionality.

The former kind of changes bring a performance benefit, but extended functionality might lead to a poorer performance.

I don't know what is the relationship between these kinds of changes. Probably you will have to do some profiling on yourself.

glglgl
  • 89,107
  • 13
  • 149
  • 217