Skip to content

Commit 8521d96

Browse files
eendebakptclaude
andcommitted
gh-NNNN: Vendor {fmt} 12.1.0 float path into Python/_fmt/
Drops the four files needed to replace _Py_dg_dtoa's float-to-string role: format.h, format-inl.h, base.h, and the upstream LICENSE. No integration yet — later commits add the C ABI shim (fmt_dtoa.cc), the build rules, and the pystrtod.c/floatobject.c call-site changes. Files are taken unmodified from upstream fmt v12.1.0 (commit 407c905), MIT-licensed. See Python/_fmt/README.vendor for the trimming rationale and a refresh procedure. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 325a46a commit 8521d96

5 files changed

Lines changed: 9423 additions & 0 deletions

File tree

Python/_fmt/LICENSE

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
Copyright (c) 2012 - present, Victor Zverovich and {fmt} contributors
2+
3+
Permission is hereby granted, free of charge, to any person obtaining
4+
a copy of this software and associated documentation files (the
5+
"Software"), to deal in the Software without restriction, including
6+
without limitation the rights to use, copy, modify, merge, publish,
7+
distribute, sublicense, and/or sell copies of the Software, and to
8+
permit persons to whom the Software is furnished to do so, subject to
9+
the following conditions:
10+
11+
The above copyright notice and this permission notice shall be
12+
included in all copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21+
22+
--- Optional exception to the license ---
23+
24+
As an exception, if, as a result of your compiling your source code, portions
25+
of this Software are embedded into a machine-executable object form of such
26+
source code, you may redistribute such embedded portions in such object form
27+
without including the above copyright and permission notices.

Python/_fmt/README.vendor

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
Vendored subset of the {fmt} library, used by Python/pystrtod.c for
2+
float-to-string conversion (replaces the David Gay dtoa machinery that
3+
lived in Python/dtoa.c).
4+
5+
Upstream: https://github.com/fmtlib/fmt
6+
Version: 12.1.0 (tag v12.1.0, commit 407c905)
7+
License: MIT (see LICENSE in this directory)
8+
9+
Files included:
10+
11+
format.h — core float formatting path, Dragon4 bignum, Dragonbox
12+
shortest entry point declaration
13+
format-inl.h — out-of-line Dragonbox tables and helpers; #include'd
14+
exactly once from fmt_dtoa.cc
15+
base.h — buffer, basic_fp, and utility types that format.h
16+
depends on
17+
LICENSE — upstream MIT license text
18+
19+
Deliberately excluded: chrono.h, color.h, compile.h, core.h, os.h,
20+
ostream.h, printf.h, ranges.h, std.h, xchar.h, args.h. None of these are
21+
reachable from the float path; keeping them out of the tree avoids
22+
dragging locale/iostream/chrono dependencies into libpython.
23+
24+
The actual bridge between fmt and CPython is Python/_fmt/fmt_dtoa.cc,
25+
which wraps fmt::detail::format_float and fmt::detail::dragonbox::to_decimal
26+
behind an extern "C" _Py_fmt_dtoa entry point matching the old
27+
_Py_dg_dtoa calling convention.
28+
29+
Build configuration:
30+
31+
$(CXX) -std=c++17 -fno-exceptions -fno-rtti
32+
33+
fmt auto-detects -fno-exceptions via __cpp_exceptions and replaces its
34+
throw sites with assertion failures. No RTTI is required on the float
35+
path.
36+
37+
Updating:
38+
39+
git clone --branch vX.Y.Z --depth 1 https://github.com/fmtlib/fmt.git
40+
cp fmt/include/fmt/{format.h,format-inl.h,base.h} Python/_fmt/
41+
cp fmt/LICENSE Python/_fmt/
42+
43+
Then update this file's version and commit hash.

0 commit comments

Comments
 (0)