Python un-plugging the Interpreter

Steve Holden steve at holdenweb.com
Fri Apr 20 05:02:52 EDT 2007


Marc 'BlackJack' Rintsch wrote:
> In <xRRVh.11903$Kd3.4637 at newssvr27.news.prodigy.net>, John Nagle wrote:
> 
>>     Many cases are easy.  If a smart compiler sees
>>
>> 	for i in range(n) :
>> 	   ... # something
>>
>> and there are no other assignments to "i", then it's clear that
>> "i" can be represented as an integer, without "boxing" into a
>> general object.
> 
> How is it clear that `i` is restricted to integers?  That works only if
> you assume `range` refers to the built-in `range()` function.  So the
> smart compiler has to check all possible control flows up to this point
> and be sure `range` was not bound to something different.
> 
That is, of course, exactly what a smart compiler would do. Only 
nowadays it would quite possibly do it just-in-time (so I suppose you 
might call it the run-time, though the boundary is continually getting 
more blurred) rather than as the result of static analysis, so it would 
*know* that the built-in generator had been called.

regards
  Steve
-- 
Steve Holden       +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd          http://www.holdenweb.com
Skype: holdenweb     http://del.icio.us/steve.holden
Recent Ramblings       http://holdenweb.blogspot.com




More information about the Python-list mailing list