On Wed, 02 Mar 2011 19:45:16 -0800, Yingjie Lan wrote: > Hi everyone, > > Variables in Python are resolved dynamically at runtime, which comes at > a performance cost. However, a lot of times we don't need that feature. > Variables can be determined at compile time, which should boost up > speed. [...]
This is a very promising approach taken by a number of projects. Cython and Pyrex are compilers that take Python-like code with static type declarations and use it to produce compiled C code. PyPy is an implementation of Python with a JIT compiler that aims to eventually rival C for speed; it's currently about twice the speed of CPython for many tasks. It was based on the earlier project, Psyco. Neither Psyco nor PyPy require type declarations, the optimized path is taken at runtime according to the type of the data. In principle, the use of runtime data can enable the compiler to generate code which is significantly faster than would be generated at compile time. Finally, Python 3 introduced type annotations, which are currently a feature looking for a reason. -- Steven -- http://mail.python.org/mailman/listinfo/python-list