Actually, after saying I was opposed to __bin__ in 2.6, I said:
"Instead, I think the approach used in 3.0 (r64451) should be used
instead. That is, if this feature exist at all. I'm -0 on adding
bin(), etc. to floats."
My last sentence is a little unclear. I meant I'm -0 on adding floats
as arguments to bin(), oct(), and hex(). Primarily because a) it's not
extensible in 3.0, and b) I find it surprising, in that I'd expect those
functions to throw an error for non-integral types (that is, those not
having __index__). I think adding a "float_as_binary_expression()"
(with a better name) in some module would get the functionality you
seek. What is gained by adding this to bin() and friends?
Raymond Hettinger wrote:
From: "Guido van Rossum" <[EMAIL PROTECTED]>
I don't care about the details of the patch until we have agreement
about which form the feature should take. We don't have that agreement
yet.
Updated to the patch to address everyone's review comments:
http://bugs.python.org/file10742/float8.diff
* Alexander Belopolsky requested exponential notation instead of
potentially very long strings of bits. Done
* Alexander Belopolsky requested true mathematical radix 2
representation of a float rather than its 64-bit memory layout. Done
* Antoine Pitrou requested that hex() and oct() be supported as well as
bin(). Terry J. Reedy also requested support for hex(). Done.
* Alexander Belopolsky and Alexandre Vassalotti requested that the
output be a two-way street -- something that can be round-tripped
through eval(). Done.
* Amaury Forgeot d'Arc requested that the implementation not manipulate
C strings inplace. Fixed -- used PyUnicode_FromFormat() instead.
* Amaury Forgeot d'Arc requested that tests should check if negative
numbers have the same representation as their absolute value. Done.
* Mark Dickinson requested sign preserving output for bin(-0.0). We
couldn't find a clean way to do this without a special cased output format.
* Mark Dickinson reviewed the NaN/Inf handling. Done.
* Eric Smith requested that the routine be attached to
_PyFloat_to_base() instead of attaching to __bin__, __oct__, and
__hex__. Done.
* Guido requested that the docs be updated. Done.
* Guido requested that the globally visible C API function name be
prefixed with _Py. Done.
* Mark Dickinson requested normalizing output to start with a 1 so that
nearby values have similar reprs. Done.
Raymond
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/eric%2Bpython-dev%40trueblade.com
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com