Getting rid of bitwise operators in Python 3?

Carl Banks pavlovevidence at gmail.com
Sat Sep 22 03:03:30 EDT 2007


On Sat, 22 Sep 2007 05:19:42 +0000, Grant Edwards wrote:
> On 2007-09-22, Carl Banks <pavlovevidence at gmail.com> wrote:
> 
>> Anyone with me here?  (I know the deadline for P3 PEPs has passed; this
>> is just talk.)
> 
> Not me.
> 
>> Not many people are bit-fiddling these days.
> 
> I do.

Your anecdotal evidence is noted and given all the consideration it's due.


>> 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.
> 
> I do it all the time.

Anecdotes again.  Do you have any stats on the usage of hardware 
interfacing in Python?  That would be a lot more useful.


> Bit fiddling is also required for implementing communications
> prototocols.

Fair enough.  That is a big issue, and defintely common on Python.


>> 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.
> 
> If you don't want to use the bitwise operations, then ignore them. 
> Presto!  Simpler syntax.

Until people no longer need to read code written by others, this argument 
is utter bull.

It's completely besides the point, anyways.  The point is to make the 
language core smaller.  It would shift code implementing bitwise logic 
out the core parts of Python, and localize it in modulespace.  It's not 
about trying to make the mental footprint of the language smaller; in 
fact, wouldn't do that at all.


>> 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 resulting code wold be fugly.

Of course it would be.  The reason I mention it is that automatic 
convertibility is a key factor in whether a change can make it into 
Python 3.


Carl Banks



More information about the Python-list mailing list