[Python-Dev] floatformat vs float_format

David Cournapeau cournape at gmail.com
Fri Jan 2 07:31:37 CET 2009


On Thu, Jan 1, 2009 at 6:43 PM, Eric Smith <eric at trueblade.com> wrote:
> David Cournapeau wrote:
>>
>> Hi,
>>
>> In python 2.6, there have been some effort to make float formatting
>> more consistent between platforms, which is nice. Unfortunately, there
>> is still one corner case, for example on windows:
>>
>> print a -> print 'inf'
>> print '%f' % a -> print '1.#INF'
>>
>> The difference being that in the second case, the formatting is done
>> in floatformat.c (in stringobject.c), whereas in the first case, it is
>> done in format_float (in floatobject.c). Shouldn't both functions be
>> calling the same underlying implementation, to avoid those
>> inconsistencies ?
>
> Yes, float formatting definitely needs some rationalization.
>
> While this isn't the exact issue discussed in
> http://bugs.python.org/issue3382, it is related, and Windows is the reason I
> had to back my fix out right before the freeze for 2.6 and 3.0. It's on my
> list of things to fix.
>
> http://bugs.python.org/issue4482 might also be related, and I'll fix that,
> too.
>
> If you could either add a comment to 3382 (with this test case) or open
> another bug and assign it to me (eric.smith), I'd appreciate it.

I did open a new bug, with a first not-so-good patch at
http://bugs.python.org/issue4799

I am not so familiar with python core code organization: where should
a function used by several core objects (here floatobjects.c and
stringobject.c, and potentially complexobject.c as well later) go ?
Since the float_format is private, is it OK to change its API (to
return a potential error instead of no return value) ?

thanks,

David


More information about the Python-Dev mailing list