A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2005-September/056529.html below:

[Python-Dev] "and" and "or" operators in Py3.0

[Python-Dev] "and" and "or" operators in Py3.0 [Python-Dev] "and" and "or" operators in Py3.0Raymond Hettinger raymond.hettinger at verizon.net
Tue Sep 20 06:57:17 CEST 2005
> > 3) Even when it isn't being used, the possibility of non-boolean
return
> > value complicates the bytecode and parser.  To allow for "and/or",
the
> > conditional opcodes leave the tested value on the stack.  In most
cases
> > both branches go directly to a POP_TOP instruction.  Since the
POP_TOP
> > shouldn't be executed twice, the body of the positive branch has to
> > close with a jump over the other branch even when it is empty.
> 
> The solution to that is for the normal conditional opcodes
> to pop the stack, and to introduce separate bytecodes for
> implementing 'and' and 'or'. 

You're right.  The bytecode code be fixed-up right now with no change to
the language :-)

That leaves error reduction and clarity as the main motivations for
changing 'and' and 'or' to act like '&&' and '||' and for introducing a
conditional operator to handle everyone's favorite use cases.


Raymond

More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4