Does Python need a '>>>' operator?

Greg Ewing greg at cosc.canterbury.ac.nz
Mon Apr 15 22:29:29 EDT 2002


Tim Peters wrote:
> 
> [Greg Ewing]
> > The way I see it, if you're doing bit twiddling
> > using unified ints/longs, you should always be
> > working with *positive* integers
> 
> Viewing longs as characteristic bit vectors, they model finite and co-finite
> sets.

Well, I meant finite bit strings,
which is what people twiddle most of the time.

> Only finite sets "look positive"; co-finite sets "look negative".  It
> doesn't take more than the unary ~ operator to go from one kind to the
> other

Yes, that's a bit of a nuisance. Whenever you
do a complement, you really need to specify how
many bits you're complementing somehow, e.g.

  y = ~x & 0x0ffffffff

The neatest solution would be to have a special
fixed-length-bit-string type. Maybe if array.array
grows a boolean type option, we could give it
& | ~ << >> operators too.

Come to think of it, bit operators would apply
quite nicely to array.arrays of char/short/long
too.

-- 
Greg Ewing, Computer Science Dept, University of Canterbury,	  
Christchurch, New Zealand
To get my email address, please visit my web page:	  
http://www.cosc.canterbury.ac.nz/~greg



More information about the Python-list mailing list