[Python-Dev] Can Python implementations reject semantically invalid expressions?
Steven D'Aprano
steve at pearwood.info
Sat Jul 3 01:38:13 CEST 2010
Wow! I didn't expect anywhere near this amount of interest. Thanks to
all who responded. One small comment follows:
On Sat, 3 Jul 2010 03:44:05 am Guido van Rossum wrote:
> On Fri, Jul 2, 2010 at 10:28 AM, Nick Coghlan <ncoghlan at gmail.com>
wrote:
> > Given the diverse range of uses Python is put to, moving things
> > from runtime to compile time can definitely have significant
> > unexpected consequences (hence why many of us would be hesitant to
> > consider an implementation that made such changes to be an actual
> > Python implementation).
>
> +1 on not changing this.
>
> For one, this will most likely break a large amount of 3rd party and
> stdlib software -- there are tons of statements like this that are
> practically unreachable or intentional.
>
> Second, I don't think it's going to make the kind of difference the
> OP is thinking of.
As I said in my initial post, this was a hypothetical, not a serious
suggestion for a change, so I'm not pushing for it. I'm not even sure I
would vote for change -- somebody asked on #python whether
implementations were free to reject semantically impossible code at
compile-time, my first instinct was to say Yes, and then I thought
about it a bit more and thought "maybe not" and decided to ask here.
I'm glad I did, because I've learned a lot.
*If* such a change was made, I think it would have to be controlled by a
command-line switch or environmental variable, like -O, and documented
as potentially changing the behaviour of the program. But given how few
accidental errors are likely to be caught by this, I doubt it would be
of any real benefit.
Thanks to all who answered!
--
Steven D'Aprano
More information about the Python-Dev
mailing list