Differences between revisions 1 and 2
Revision 1 as of 2008-08-12 05:37:01
Size: 197
Editor: ZoomQuiet
Comment: init. answer
Revision 2 as of 2008-08-12 22:13:09
Size: 1546
Editor: MichaelFoord
Comment:
Deletions are marked like this. Additions are marked like this.
Line 5: Line 5:

 Another answer::
  * Python as a language is a set of rules (its syntax and semantics) and so doesn't have a 'speed'. Only a specific language implementation can have a measurable speed, and then we can only compare the performance of specific implementations with an implementation of another language. In general you can't compare the speed of one language to another - only compare implementations. With Python there are several implementations - CPython (with or without Psyco), IronPython, Jython, PyPy - plus several partial implementations that implement a subset of Python (Tinypy) or can even compile a subset of Python to C++ (Shedskin). If you say Python is slow, which specific implementation are you talking about? Having said that, as a dynamic language Python will typically perform slower for specific benchmarks than standard implementations of some other languages (although it is faster than plenty of others). As a dynamic language a lot of information about the program (the type of variables) can only be determined at runtime. This means that a lot of common compiler tricks, that rely on knowing the type of objects at compile time, can't work. Despite this there are a lot of things that can be done to improve the performance of dynamic language, several of which are being explored in the PyPy JIT tracing compiler.

SEE:[wiki:Ten_things_people_want_to_know_about_Python Ten things people want to know about Python]for more details.

Answer
  • Why not ask:"Why is Python fast than the xxx language"?
Another answer
  • Python as a language is a set of rules (its syntax and semantics) and so doesn't have a 'speed'. Only a specific language implementation can have a measurable speed, and then we can only compare the performance of specific implementations with an implementation of another language. In general you can't compare the speed of one language to another - only compare implementations. With Python there are several implementations - CPython (with or without Psyco), IronPython, Jython, PyPy - plus several partial implementations that implement a subset of Python (Tinypy) or can even compile a subset of Python to C++ (Shedskin). If you say Python is slow, which specific implementation are you talking about? Having said that, as a dynamic language Python will typically perform slower for specific benchmarks than standard implementations of some other languages (although it is faster than plenty of others). As a dynamic language a lot of information about the program (the type of variables) can only be determined at runtime. This means that a lot of common compiler tricks, that rely on knowing the type of objects at compile time, can't work. Despite this there are a lot of things that can be done to improve the performance of dynamic language, several of which are being explored in the PyPy JIT tracing compiler.

Why is Python slower than the xxx language (last edited 2008-11-15 13:59:37 by localhost)

Unable to edit the page? See the FrontPage for instructions.