Why I love python.

Reinhold Birkenfeld reinhold-birkenfeld-nospam at wolke7.net
Fri Aug 13 14:03:39 EDT 2004


Nick Patavalis wrote:
> On 2004-08-13, Erik Max Francis <max at alcyone.com> wrote:
>> Erik de Castro Lopo wrote:
>>> 
>>> Its called type inferencing and since there is at least one working
>>> implementation, it can't be THAT hard.
>>
>> That's actually the kind of thing that is planned for Python with
>> Starkiller, however silly a project name that might be.
>>
> 
> Correct me if I'm wrong, but I thing that starkiller produces
> optimized code (i.e. native code) only if it can unambiguously
> inference the types a-priori, and there are cases (in a dymanically
> typed language like python) where this is impossible. In these cases,
> I believe, starkiller does nothing. Are there any plans for treating
> such cases? And how?

I think the dynamic nature does make it impossible to do anything in
such cases at the first place. Consider:

klass = raw_input()
classobj = eval(klass + "()")
print classobj.whatami

A compiler can tell absolutely _nothing_ about the resulting class
object since typing information is not contained in the program.

One would have to tell the "compiler" explicitly which types the
variable will be allowed to hold, such as:

klass = raw_input()
classobj as (FooObject, BarObject, BazInterface) = eval(klass + "()")
print classobj.whatami

But that requires "typed Python" extensions, and as such isn't pure type
inferencing any more.

Reinhold

-- 
Wenn eine Linuxdistribution so wenig brauchbare Software wie Windows
mitbrächte, wäre das bedauerlich.  Was bei Windows der Umfang eines
"kompletten Betriebssystems" ist, nennt man bei Linux eine Rescuedisk.
  -- David Kastrup in de.comp.os.unix.linux.misc



More information about the Python-list mailing list