Commit 8433b87
gh-NNNN: Route float→string through _Py_fmt_dtoa
Swap the _Py_dg_dtoa / _Py_dg_freedtoa call pair at its two in-tree call
sites (pystrtod.c's format_float_short and floatobject.c's
double_round) for _Py_fmt_dtoa / _Py_fmt_dtoa_free. Covers all three
CPython dtoa modes bit-exactly:
* mode 0 (shortest / repr): fmt::detail::dragonbox::to_decimal
* mode 2 (N sig digits): fmt::detail::format_float, specs=exp
* mode 3 (N frac digits): fmt::detail::format_float, specs=fixed
fmt's format_float with specs=exp takes `precision` as total-digits-to-
emit (not "digits after the leading one"), so for mode 2 we pass N
directly. For specs=fixed fmt's adjust_precision adds the decade and
handles negative precision natively, which is what mode 3 with negative
ndigits wants.
Python/dtoa.c is still in the build for _Py_dg_strtod (commit 7 handles
that swap) but _Py_dg_dtoa is now unreferenced.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent ffc3525 commit 8433b87
2 files changed
Lines changed: 10 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
900 | 900 | | |
901 | 901 | | |
902 | 902 | | |
903 | | - | |
| 903 | + | |
| 904 | + | |
904 | 905 | | |
905 | 906 | | |
906 | 907 | | |
| |||
914 | 915 | | |
915 | 916 | | |
916 | 917 | | |
917 | | - | |
| 918 | + | |
918 | 919 | | |
919 | 920 | | |
920 | 921 | | |
| |||
951 | 952 | | |
952 | 953 | | |
953 | 954 | | |
954 | | - | |
| 955 | + | |
955 | 956 | | |
956 | 957 | | |
957 | 958 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
980 | 980 | | |
981 | 981 | | |
982 | 982 | | |
983 | | - | |
984 | | - | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
985 | 986 | | |
986 | | - | |
987 | | - | |
| 987 | + | |
| 988 | + | |
988 | 989 | | |
989 | 990 | | |
990 | 991 | | |
| |||
1212 | 1213 | | |
1213 | 1214 | | |
1214 | 1215 | | |
1215 | | - | |
| 1216 | + | |
1216 | 1217 | | |
1217 | 1218 | | |
1218 | 1219 | | |
| |||
0 commit comments