Proposal: local variable declarations and type advice
phr-n2002a at nightsong.com
Wed Feb 27 10:14:19 EST 2002
"Raymond Hettinger" <othello,javanet at rcn.com> writes:
> 4) Code is generated along the lines of:
> if type('banana')==int:
> <run optimized code that assumes 'banana' to be an int>
> elseif USESTRICT:
> raise TypeError
> <run normal, slow code which binds 'banana' to int regardless of type>
> In other words, generate optimized code in case the type advice is correct;
> otherwise, run normally unless strict type checking is in effect.
But part of the optimization is to skip the type checking. For example,
something declared int can be stored in a machine register with no type
bits, rather than as a tagged word or as a pointer to something in the
> This allows optimization based on the advice and error checking only when
Yes, the proposal is the programmer decides when to request optimization
and when to request error checking. Normally you'd leave error checking on
> In general, I like your proposals (after Greg Ewing's correction).
> It reminds of importing packages in that it is a simple tool for
> building large, fast, reliable programs while staying out of the way
> (and out of mind) for more casual programming.
Thanks, that summarizes the intention pretty well.
More information about the Python-list