On Dec 12, 4:45 am, "Terry Reedy" <[EMAIL PROTECTED]> wrote: > "sturlamolden" <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > | We could include optional static typing in > | Python, and have an optional static optimizing native compiler for > | selected portions of code. > > Python 3 will have optional 'type' annotations, where 'type' includes > abstract base classes defined by the interface (methods). So parameters > could be annotated as a Number or Sequence, for instance, which is more > useful often than any particular concrete type. I strongly suspect that > someone will use the annotations for compilation, which others will use > them just for documentation and whatever else. > > tjr
On the danger of hurting some souls, I used to write a type feedback system a few months ago, which automatically annotates source code from runtime types. Each run of a program P yields a program TP which is fully type annotated on covered branches. Since a possible compiler might need more hints than just relying on the types of function parameters I changed the syntax of Python slightly for displaying local type annotations as well. For each Python program P exist possibly infinitely many programs TP of an extended languages TPython called "typed snapshots". Each of those snapshots might be translated using translation machinery a la ShedSkin. From a software engineering point of view early integration with CPython is required, which means integration of native code on a per function base and possible fallback to bytecode interpretation in order to preserve duck-typing. In the literature such techniques are called "(Offline) Feedback Driven Optimization", while "Online" techniques refer to JIT compilation. When TP is yielded from P the program TP might be used for other purposes as well because each typed snaphsot suggests static guarantees in a given type system. This might ease the productive value of refactoring browsers or other tools used for languages with type systems. I'm yet not sure about type systems for typed snapshots but one might interpret them in an existing languages with type systems. Kay -- http://mail.python.org/mailman/listinfo/python-list