[issue9009] Improve quality of Python/dtoa.c

2010-06-16 Thread Mark Dickinson
New submission from Mark Dickinson : I've opened this issue to track efforts to improve the quality of the Python/dtoa.c file, which provides Python's string-to-float and float-to-string conversions. Particular issues in mind (non-exhaustive): - do a thorough review and test of _Py_dg_dtoa;

[issue9009] Improve quality of Python/dtoa.c

2010-06-16 Thread Alexander Belopolsky
Changes by Alexander Belopolsky : -- nosy: +belopolsky ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://ma

[issue9009] Improve quality of Python/dtoa.c

2010-06-16 Thread Mark Dickinson
Mark Dickinson added the comment: Created new 'py3k-dtoa' branch for this work in r82024. -- ___ Python tracker ___ ___ Python-bugs-li

[issue9009] Improve quality of Python/dtoa.c

2010-06-16 Thread Mark Dickinson
Mark Dickinson added the comment: A couple of preparatory commits: r82025: In _Py_dg_strtod, 'e' now represents the adjusted exponent rather than the base exponent; that is, the input value is of the form +- m * 10**e with 0.1 <= m < 1.0. It's easier to produce such an 'e' from the parsing

[issue9009] Improve quality of Python/dtoa.c

2010-06-16 Thread Mark Dickinson
Mark Dickinson added the comment: And here's a patch to pull out the parsing stage of _Py_dg_strtod into a separate function. -- keywords: +patch Added file: http://bugs.python.org/file17688/dtoa_parsing.patch ___ Python tracker

[issue9009] Improve quality of Python/dtoa.c

2010-06-16 Thread Mark Dickinson
Mark Dickinson added the comment: r82032: Commit some additional tests for test_strtod.py. test_extra_long_significand will currently fail; with the dtoa_parsing patch, it passes. -- ___ Python tracker _

[issue9009] Improve quality of Python/dtoa.c

2010-06-16 Thread Mark Dickinson
Changes by Mark Dickinson : -- stage: -> patch review type: -> feature request ___ Python tracker ___ ___ Python-bugs-list mailing li

[issue9009] Improve quality of Python/dtoa.c

2010-06-16 Thread Eric Smith
Eric Smith added the comment: I realize the ship's already sailed on this issue [1], but isn't it a problem that editing this code makes it more difficult to apply patches from Gay's original code? What do we do if Gay releases a new version of his code with bug fixes? [1] Sorry non-native

[issue9009] Improve quality of Python/dtoa.c

2010-06-16 Thread Mark Dickinson
Mark Dickinson added the comment: Gay's changes tend to be very small; any bugfixes he releases can likely be applied by hand, if they're relevant. I did originally want to keep close to Gay's code, but frankly I'm not very happy with the quality of that code; and in communications with Gay

[issue9009] Improve quality of Python/dtoa.c

2010-06-16 Thread Mark Dickinson
Mark Dickinson added the comment: Here's the section of the 'bigcomp' code that I was referring to above: /* Now b/d = exactly half-way between the two floating-point values */ /* on either side of the input string. Compute first digit of b/d. */ if (!(dig = quorem(b,d

[issue9009] Improve quality of Python/dtoa.c

2010-06-16 Thread Eric Smith
Eric Smith added the comment: Just to be clear: I'm okay with this divergence, as long as we've made it clear we're explicitly doing so and we've given our reasons. Mark's done that, and of course he's the expert in the subject. -- ___ Python tracker

[issue9009] Improve quality of Python/dtoa.c

2010-06-16 Thread Mark Dickinson
Mark Dickinson added the comment: Here's an updated version of the parsing patch, with rewritten comments, but no significant code changes. -- Added file: http://bugs.python.org/file17689/dtoa_parsing2.patch ___ Python tracker

[issue9009] Improve quality of Python/dtoa.c

2010-06-16 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Mark, It is great to see you doing this. I looked at this code on several occasions before and each time ran away scared! I sincerely hope I will understand how it works after your rewrite. Just a small suggestion at this point: can you give longer n

[issue9009] Improve quality of Python/dtoa.c

2010-06-18 Thread Mark Dickinson
Mark Dickinson added the comment: r82079: Apply a version of the parsing patch to pull the parsing code out into a separate function. Alexander, I agree about the names; I'll do a mass renaming later on. I'm trying not to mix the significant algorithm-changing commits with trivial renam

[issue9009] Improve quality of Python/dtoa.c

2010-06-18 Thread Eric Smith
Eric Smith added the comment: It would be easier for me to review if you did it in the other order: fix the variable names first. Although I'm still pretty busy and won't have much time to review, so my needs shouldn't be your first priority. -- _

[issue9009] Improve quality of Python/dtoa.c

2010-06-19 Thread Mark Dickinson
Mark Dickinson added the comment: r82080: Whitespace fixes. r82081: In strtod, simplify the computation of the initial approximation. r82082: Fix typo introduced in r82025 (I think); this was preventing a shortcut from being taken. r82087: Simplify the ratio function. The previous ratio fu

[issue9009] Improve quality of Python/dtoa.c

2010-06-19 Thread Mark Dickinson
Mark Dickinson added the comment: Patch that does a fairly significant rewrite of strtod; it's still (mostly) based on Gay's code, but there are some significant changes. Some background: strtod, after dealing with easy cases, works roughly as follows: (1) Using floating-point arithmetic,

[issue9009] Improve quality of Python/dtoa.c

2010-06-24 Thread Mark Dickinson
Mark Dickinson added the comment: Another issue to consider, brought to my attention by Rick Regan: Python's dtoa.c code likely misbehaves (i.e., returns incorrectly rounded results) if the FPU rounding mode is anything other than the round-half-to-even default. (This is also true of Gay's

[issue9009] Improve quality of Python/dtoa.c

2010-06-24 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: > - ignore the rounding mode completely, always doing round-half-to-even. +1 -- ___ Python tracker ___ ___

[issue9009] Improve quality of Python/dtoa.c

2010-06-24 Thread Eric Smith
Eric Smith added the comment: > > Alexander Belopolsky added the comment: > >> - ignore the rounding mode completely, always doing round-half-to-even. > +1 Agreed. +1 -- ___ Python tracker ___

[issue9009] Improve quality of Python/dtoa.c

2010-06-24 Thread Stefan Krah
Stefan Krah added the comment: +1, if the FPU mask is always restored (as I understand, this is the case now). -- nosy: +skrah ___ Python tracker ___

[issue9009] Improve quality of Python/dtoa.c

2010-07-06 Thread Mark Dickinson
Mark Dickinson added the comment: Second version of the strtod rewrite; has some additional documentation and comment fixes. No other significant changes from the first version. This is still a work in progress. -- Added file: http://bugs.python.org/file17883/rewrite_strtod_v2.patc

[issue9009] Improve quality of Python/dtoa.c

2010-07-06 Thread Mark Dickinson
Mark Dickinson added the comment: r82614: add functionality to change FPU rounding mode (via float.__setround__ and float.__getround__ functions), on platforms that support the standard C99 fesetround and fegetround functions: >>> float.__getround__() 'tonearest' >>> 1e300 * 1e300 inf >>> flo

[issue9009] Improve quality of Python/dtoa.c

2010-08-08 Thread Mark Dickinson
Mark Dickinson added the comment: Version of the rewrite_strtod patch applied in r83813. -- ___ Python tracker ___ ___ Python-bugs-lis

[issue9009] Improve quality of Python/dtoa.c

2012-04-29 Thread Mark Dickinson
Mark Dickinson added the comment: Dropping this due to lack of time; unless anyone else wants to pick it up, it should probably be closed as "won't fix". -- assignee: mark.dickinson -> priority: normal -> low ___ Python tracker

[issue9009] Improve quality of Python/dtoa.c

2011-12-01 Thread Rick Regan
Rick Regan added the comment: > if (!(dig = quorem(b,d))) { > b = multadd(b, 10, 0); /* very unlikely */ > dig = quorem(b,d); > } > > This code is part of the algorithm for strtod. Here b and d are > Bigints, and b / d is a fraction that gives a