[Python-Dev] Can Python implementations reject semantically invalid expressions?
Greg Ewing
greg.ewing at canterbury.ac.nz
Sat Jul 3 03:39:07 CEST 2010
Stefan Behnel wrote:
> So, would it still be Python if it folded
>
> 1 + "1"
>
> into
>
> raise TypeError()
>
> at compile time?
It would have to be
raise TypeError("Exactly the message that would have been produced at run time")
That might be acceptable, but then you have to ask, is it really
worth performing this optimisation? The overhead of raising and
handling the exception is likely to completely swamp that of
executing the original code.
--
Greg
More information about the Python-Dev
mailing list