Rationale for core Python numeric types

Tim Peters tim.peters at gmail.com
Thu Jul 15 20:28:29 CEST 2004


[Aahz]
>> Python 3.0 won't even offer a fixed-size integer type -- it'll all be the
>> unbounded Python long type (mostly --

[Josef Dalcolmo]
> If that is true, many of my data acquisition programs won't work any more,
> because besides using the struct module, I do have a need for occasional bit
> fiddling (masking, concatenating, setting, resetting, toggling, shifting, rotating) of
> bits in a particular word that represents some register on a hardware device.

You're too worried.  The only real semantic difference is that a left
shift won't throw away bits by magic, and in a platform-dependent way,
anymore.  BFD -- '&' the result with a mask to retain just the
low-order bits you want.  That's the only way to do
platform-*independent* "short int" left shifts in Python already. 
Right-shift and boolean and/or/xor/complement are unaffected. 
"setting", "resetting" and "toggling" are special cases of boolean
and/or/xor/complement, so are unaffected.  Don't know what you mean by
"concatenating".  Python has never had direct support for rotating, so
that's also unaffected <wink>.



More information about the Python-list mailing list