Q: Python 2.0 preliminary features?

Neel Krishnaswami neelk at brick.cswv.com
Mon Oct 11 11:33:47 EDT 1999


On Mon, 11 Oct 1999 12:16:15 +1000, skaller <skaller at maxtal.com.au> wrote:
>
>In the third stage, type inference will attempt to ascribe types to
>the variables, and use some fixed ad hoc speedups to improve
>interpreter speed even further.

How do you plan to mix type inference and extension-type/Python-class
unification? 

As I understand it, type inference in OO languages is generally only a
win if you can do enough to infer the actual runtime type of the
object. IOW, it's not enough to know that the object is an instance of
some subclass of the class Number, but that it's a direct instance of
the class Integer.  Then you can avoid paying the cost of polymorphic
dispatch, and can take advantage of knowing the actual method called
to do additional optimizations (like inlining).

But if Python's primitive types are made into real Python classes,
then any type can be potentially be subclassed, which makes inferring
the runtime type a much harder prospect. 

AFAICT, you need to either add something like Java's "final" keyword,
do whole-program analysis (does eval defeat this?), or do dynamic
compilation like Self. Or are there some cool new tricks you can steal
for Viper from the OCaml compiler..?


Neel




More information about the Python-list mailing list