Nick Coghlan <[EMAIL PROTECTED]> added the comment:

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.

----------
nosy: +ncoghlan

__________________________________
Tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue2483>
__________________________________
_______________________________________________
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to