Anyone with me here? (I know the deadline for P3 PEPs has passed; this is just talk.)
Not many people are bit-fiddling these days. One of the main uses of bit fields is flags, but that's not often done in Python because of keyword arguments and dicts, which are lot more versatile. Another major use, talking to hardware, is not something oft done in Python either. It seems like this occasional usage wouldn't justify having built-in operators on its own. And with the int/long unification, it makes a bit less sense to think of integers as a bit field. Python has these operators because of its heritage, but Python continues to move away from the bad habits of its ancestors (integer division and so on), and I wonder if this isn't another one. Of course I'm not suggesting to get rid of bitwise operations altogether; just make them builtin functions: "x & 1" becomes "bitwise_and(x,1)" and so on. Is it worth it to make such a change? It would remove a lot of operators (11 by my count), vastly simplifying syntax, Which, IMHO, is no small thing. New numerical types would have fewer operations to support. And let's face it: unlike arithmetic opertaions, there's not a lot of different meanings for bit operations. And it would also, um, make new special characters available *cough*. Obviously, how widespread their usage is would matter. But keep in mind it would also be easy to convert the code automatically, because the Python parser could reliably find all bitwise operations reliably. (The problem would be types that overloaded them to be something other than bitwise operations: I'm looking at you, set. That could very well be a deal breaker. I've never approved of things with completely different meanings being deliberately overloaded to have the same spelling; this is one reason why.) If anyone says, "But that takes away an easy test for oddness (x&1)!", or, "But you can multiply powers of two using left shift! Isn't that cool?", I'm not buying it. Those are gimmicks. Arithmetic operations should be done with arithmetic operators. The bitwise operators make the code much less readable, especially to people unfamiliar with this usage. the-above-pun-was-intended-ly yr's, Carl Banks -- http://mail.python.org/mailman/listinfo/python-list