[Python-ideas] overloading chained comparison
Greg Ewing
greg.ewing at canterbury.ac.nz
Wed Mar 19 01:03:06 CET 2014
Nathaniel Smith wrote:
> This does solve our problematic case above: only 'arr' implements
> __chain_comparison__, so we have
> 0 < x < arr
> becoming
> arr.__chain_comparison__([0, x, arr], [operator.lt, operator.lt])
I don't see how that works, because you need to evaluate
arr in order to tell whether it has a __chain_comparison__
method. So chained comparisons would always have to evaluate
all operands and could never short-circuit.
--
Greg
More information about the Python-ideas
mailing list