[Python-Dev] Re: ANN: PEP 335: Overloadable Boolean Operators (original) (raw)

Tim Hochberg tim.hochberg at ieee.org
Tue Sep 14 21:50:00 CEST 2004


Phillip J. Eby wrote:

[CHOP]

As for the numeric use cases, I'm not at all clear why &, |, and ~ (or special methods/functions) aren't suitable.

They often are, but sometimes you want a logical and/or/not and &/|/~ are mapped to bitwise and/or/not, which isn't always what you want. Presumably, if Gregs proposal were adopted, and/or/not would get mapped to numarray.logical_and/or/not.

What I find more interesting about this proposal is that one could probably finagle it so that (A < B < C) worked correctly for arrays. It can't work now since it is equivalent to ((A < B) and (B < C)) and 'and' doesn't do anything sensible for arrays at present. This is one I always expect to work even though I know that and/or/not don't work for arrays.

-tim



More information about the Python-Dev mailing list