[EMAIL PROTECTED] wrote:
Viile writes -

Type declarations are a feature that might benefit IronPython and
Jython more than they would CPython.

How much is this part of Guido's decisionmaking process?

One major reason to allow optional static typing is to aid specializing compilers. A language called "Self" had a type system even more dynamic than Python's, and it was capable of getting to quite reasonable speeds doing dynamic analysis and specialization. In fact, PyPy is quite likely to get great optimization from the declarations as well as IronPython and JPython.

If for some reason you know the arguments to a function are all
integers, you can create a translation of that function that
only operates on integers, and you can often discover that
operations not only on the arguments, but on partial results,
can all be kept as integers.  These operations can be translated
into very simple operations that avoid method lookup, and can
therefore run much faster.  If, conceptually, some set of
functions and methods always are called with specific types,
those functions and methods can have very high-speed (relatively)
implementations for fairly little cost in compiler complexity.
Such specifications could be spread through the standard library
(if only in the most obvious of places), and provide a _very_
_substantial_ speed improvement for less investment than almost
any of the other techniques around.

Remember, at the core, all current CPUs operate on one or two
data types: integers and floating point.  Wherever they must
distinguish types they must use conditional branches, the slowest
operation on the fastest CPUs being produced today and in the
relatively visible future.  Even when the type specification
is advice about the most common type path, rather than a strict
guarantee of the type, code can be generated that does the test
before choosing which path to choose, and have fast code on the
type-specific path.

--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to