[Python-Dev] Re: ANN: PEP 335: Overloadable Boolean Operators (original) (raw)
Perry Greenfield perry at stsci.edu
Tue Sep 14 22:55:53 CEST 2004
- Previous message: [Python-Dev] ANN: PEP 335: Overloadable Boolean Operators
- Next message: [Python-Dev] --with-tsc compile fails
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Tim Hochberg wrote:
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.logicaland/or/not. I'll go further than that. Most of the time Numeric/numarray users want logical and/or/not. Bitwise operations are, by comparison, rarely desired.
It is true that one can use the bitwise operators in place of the logical ones (and currently, that's what I tell people to use), but you better make sure the arguments are booleans or limited to 0/1 values or the result is not what is expected. In the great majority of cases the arguments are booleans, but there are times when that isn't true, and using the bitwise operators causes real grief if the user has become accustomed to using the bitwise operator mindlessly.
Furthermore, most new array users naturally expect and/or/not to operate on the array and are usually very annoyed that it doesn't work. This is one of the largest (if not the largest) remaining warts for using arrays with Python. I sure would like to see the PEP accepted. No one who has tried to write many array expressions with the functional or method equivalents would argue for their use in place of the operators.
Perry Greenfield
- Previous message: [Python-Dev] ANN: PEP 335: Overloadable Boolean Operators
- Next message: [Python-Dev] --with-tsc compile fails
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]