Message64498
I have a couple of use cases for bytes-as-ASCII-text -> int, one of
which also touches on floats. The other numeric types also accepting
bytes as representing ASCII encoded strings would then follow from a
consistency of behaviour argument.
Use case 1: Decimal implementation
The simplest way to retain the 2.x series decimal performance in 3.0 is
to switch the mantissa storage from a string to a bytes object. This is
only possible if the int constructor accepts bytes objects and treats
them as an ASCII-encoded string.
Use case 2: Serial protocols with embedded ASCII text
I work with a lot of control protocols for different pieces of hardware,
and one way the hardware vendors avoid having to write a custom control
interface for their hardware is to make their serial interface human
readable (so a terminal program like Hyperterminal or Miniterm becomes
their user interface). Writing automated control software for these
devices is essentially an exercise in screen-scraping the ASCII strings
received on the serial port. Having to go through Unicode to convert
ASCII digits embedded in these strings to numbers would be a major pain.
While these numbers are mostly integers, you do get the occasional
floating point value turning up as well, so bytes->float can also be useful. |
|
Date |
User |
Action |
Args |
2008-03-25 16:57:59 | ncoghlan | set | spambayes_score: 0.171599 -> 0.17159937 recipients:
+ ncoghlan, mark.dickinson |
2008-03-25 16:57:58 | ncoghlan | set | spambayes_score: 0.171599 -> 0.171599 messageid: <1206464278.35.0.916451352308.issue2483@psf.upfronthosting.co.za> |
2008-03-25 16:57:57 | ncoghlan | link | issue2483 messages |
2008-03-25 16:57:56 | ncoghlan | create | |
|