Victor Zverovich | f1cd541 | 2016-04-24 10:46:21 -0700 | [diff] [blame] | 1 | {fmt} |
| 2 | ===== |
vitaut | ec27d5d | 2012-12-07 08:26:46 -0800 | [diff] [blame] | 3 | |
Victor Zverovich | 5a6a585 | 2016-04-27 08:05:40 -0700 | [diff] [blame] | 4 | .. image:: https://travis-ci.org/fmtlib/fmt.png?branch=master |
| 5 | :target: https://travis-ci.org/fmtlib/fmt |
Victor Zverovich | 817d98a | 2014-04-14 23:19:38 -0700 | [diff] [blame] | 6 | |
Victor Zverovich | f4b5aea | 2016-04-27 08:13:56 -0700 | [diff] [blame] | 7 | .. image:: https://ci.appveyor.com/api/projects/status/ehjkiefde6gucy1v |
| 8 | :target: https://ci.appveyor.com/project/vitaut/fmt |
Victor Zverovich | d22d11b | 2019-05-10 09:54:42 -0700 | [diff] [blame] | 9 | |
Victor Zverovich | 08370c3 | 2020-10-17 08:27:21 -0700 | [diff] [blame] | 10 | .. image:: https://oss-fuzz-build-logs.storage.googleapis.com/badges/fmt.svg |
Victor Zverovich | c090569 | 2020-07-08 08:01:36 -0700 | [diff] [blame] | 11 | :alt: fmt is continuously fuzzed at oss-fuzz |
Victor Zverovich | 2381df6 | 2020-07-04 08:27:57 -0700 | [diff] [blame] | 12 | :target: https://bugs.chromium.org/p/oss-fuzz/issues/list?\ |
Victor Zverovich | 9e20883 | 2020-07-04 09:37:27 -0700 | [diff] [blame] | 13 | colspec=ID%20Type%20Component%20Status%20Proj%20Reported%20Owner%20\ |
Victor Zverovich | 37d738f | 2020-10-16 06:46:39 -0700 | [diff] [blame] | 14 | Summary&q=proj%3Dfmt&can=1 |
Paul Dreik | 840a817 | 2019-09-19 06:47:11 +0200 | [diff] [blame] | 15 | |
Victor Zverovich | 4afb39b | 2019-11-26 08:33:16 -0800 | [diff] [blame] | 16 | .. image:: https://img.shields.io/badge/stackoverflow-fmt-blue.svg |
| 17 | :alt: Ask questions at StackOverflow with the tag fmt |
谭九鼎 | cd2b990 | 2019-12-17 08:48:27 -0600 | [diff] [blame] | 18 | :target: https://stackoverflow.com/questions/tagged/fmt |
Victor Zverovich | 4afb39b | 2019-11-26 08:33:16 -0800 | [diff] [blame] | 19 | |
Victor Zverovich | 05a2831 | 2020-09-30 17:38:28 -0700 | [diff] [blame] | 20 | **{fmt}** is an open-source formatting library providing a fast and safe |
| 21 | alternative to C stdio and C++ iostreams. |
Victor Zverovich | 70a2317 | 2012-12-07 14:18:37 -0800 | [diff] [blame] | 22 | |
Victor Zverovich | 79ba37f | 2020-09-26 10:13:04 -0700 | [diff] [blame] | 23 | If you like this project, please consider donating to BYSOL, |
| 24 | an initiative to help victims of political repressions in Belarus: |
Victor Zverovich | 2213a71 | 2020-09-26 11:46:39 -0700 | [diff] [blame] | 25 | https://www.facebook.com/donate/759400044849707/108388587646909/. |
Victor Zverovich | 79ba37f | 2020-09-26 10:13:04 -0700 | [diff] [blame] | 26 | |
Victor Zverovich | 23063c3 | 2020-07-08 07:11:13 -0700 | [diff] [blame] | 27 | `Documentation <https://fmt.dev>`__ |
vitaut | eb50269 | 2015-05-22 06:50:46 -0700 | [diff] [blame] | 28 | |
Victor Zverovich | c56cf3d | 2020-07-04 08:20:10 -0700 | [diff] [blame] | 29 | Q&A: ask questions on `StackOverflow with the tag fmt |
| 30 | <https://stackoverflow.com/questions/tagged/fmt>`_. |
Victor Zverovich | 4c8efd6 | 2019-05-10 09:56:40 -0700 | [diff] [blame] | 31 | |
Victor Zverovich | a7c5db0 | 2020-07-28 08:18:10 -0700 | [diff] [blame] | 32 | Try {fmt} in `Compiler Explorer <https://godbolt.org/z/Eq5763>`_. |
Victor Zverovich | a4c22ac | 2020-07-26 12:12:31 -0700 | [diff] [blame] | 33 | |
Victor Zverovich | 70a2317 | 2012-12-07 14:18:37 -0800 | [diff] [blame] | 34 | Features |
| 35 | -------- |
| 36 | |
Victor Zverovich | 8fa20b4 | 2020-07-13 06:15:47 -0700 | [diff] [blame] | 37 | * Simple `format API <https://fmt.dev/latest/api.html>`_ with positional arguments |
Victor Zverovich | c56cf3d | 2020-07-04 08:20:10 -0700 | [diff] [blame] | 38 | for localization |
| 39 | * Implementation of `C++20 std::format |
| 40 | <https://en.cppreference.com/w/cpp/utility/format>`__ |
Victor Zverovich | 8fa20b4 | 2020-07-13 06:15:47 -0700 | [diff] [blame] | 41 | * `Format string syntax <https://fmt.dev/latest/syntax.html>`_ similar to Python's |
Victor Zverovich | c56cf3d | 2020-07-04 08:20:10 -0700 | [diff] [blame] | 42 | `format <https://docs.python.org/3/library/stdtypes.html#str.format>`_ |
Victor Zverovich | f80ed64 | 2020-09-14 11:13:51 -0700 | [diff] [blame] | 43 | * Fast IEEE 754 floating-point formatter with correct rounding, shortness and |
Victor Zverovich | 8924211 | 2020-10-21 14:02:55 -0700 | [diff] [blame] | 44 | round-trip guarantees |
Victor Zverovich | 86a7d85 | 2015-02-26 09:05:20 -0800 | [diff] [blame] | 45 | * Safe `printf implementation |
Victor Zverovich | 23063c3 | 2020-07-08 07:11:13 -0700 | [diff] [blame] | 46 | <https://fmt.dev/latest/api.html#printf-formatting>`_ including the POSIX |
| 47 | extension for positional arguments |
| 48 | * Extensibility: `support for user-defined types |
| 49 | <https://fmt.dev/latest/api.html#formatting-user-defined-types>`_ |
Victor Zverovich | f230170 | 2019-03-10 12:13:14 -0700 | [diff] [blame] | 50 | * High performance: faster than common standard library implementations of |
Victor Zverovich | 23063c3 | 2020-07-08 07:11:13 -0700 | [diff] [blame] | 51 | ``(s)printf``, iostreams, ``to_string`` and ``to_chars``, see `Speed tests`_ |
| 52 | and `Converting a hundred million integers to strings per second |
Victor Zverovich | 2381df6 | 2020-07-04 08:27:57 -0700 | [diff] [blame] | 53 | <http://www.zverovich.net/2020/06/13/fast-int-to-string-revisited.html>`_ |
Victor Zverovich | 23063c3 | 2020-07-08 07:11:13 -0700 | [diff] [blame] | 54 | * Small code size both in terms of source code with the minimum configuration |
| 55 | consisting of just three files, ``core.h``, ``format.h`` and ``format-inl.h``, |
| 56 | and compiled code; see `Compile time and code bloat`_ |
Victor Zverovich | e4c954f | 2020-08-07 16:03:15 -0700 | [diff] [blame] | 57 | * Reliability: the library has an extensive set of `tests |
| 58 | <https://github.com/fmtlib/fmt/tree/master/test>`_ and is `continuously fuzzed |
Victor Zverovich | 1378dda | 2020-08-08 18:01:56 -0700 | [diff] [blame] | 59 | <https://bugs.chromium.org/p/oss-fuzz/issues/list?colspec=ID%20Type%20 |
Victor Zverovich | 37d738f | 2020-10-16 06:46:39 -0700 | [diff] [blame] | 60 | Component%20Status%20Proj%20Reported%20Owner%20Summary&q=proj%3Dfmt&can=1>`_ |
Victor Zverovich | e613b3c | 2017-11-10 07:24:16 -0800 | [diff] [blame] | 61 | * Safety: the library is fully type safe, errors in format strings can be |
| 62 | reported at compile time, automatic memory management prevents buffer overflow |
Victor Zverovich | c56cf3d | 2020-07-04 08:20:10 -0700 | [diff] [blame] | 63 | errors |
Victor Zverovich | 7c697bf | 2012-12-11 16:30:27 -0800 | [diff] [blame] | 64 | * Ease of use: small self-contained code base, no external dependencies, |
Victor Zverovich | 972ffd3 | 2019-09-06 13:13:30 -0700 | [diff] [blame] | 65 | permissive MIT `license |
Victor Zverovich | e817bb9 | 2016-04-27 08:23:03 -0700 | [diff] [blame] | 66 | <https://github.com/fmtlib/fmt/blob/master/LICENSE.rst>`_ |
Victor Zverovich | 91bb3aa | 2019-05-17 15:42:00 -0700 | [diff] [blame] | 67 | * `Portability <https://fmt.dev/latest/index.html#portability>`_ with |
Victor Zverovich | c56cf3d | 2020-07-04 08:20:10 -0700 | [diff] [blame] | 68 | consistent output across platforms and support for older compilers |
Victor Zverovich | 23063c3 | 2020-07-08 07:11:13 -0700 | [diff] [blame] | 69 | * Clean warning-free codebase even on high warning levels such as |
| 70 | ``-Wall -Wextra -pedantic`` |
Victor Zverovich | c56cf3d | 2020-07-04 08:20:10 -0700 | [diff] [blame] | 71 | * Locale-independence by default |
Victor Zverovich | c56cf3d | 2020-07-04 08:20:10 -0700 | [diff] [blame] | 72 | * Optional header-only configuration enabled with the ``FMT_HEADER_ONLY`` macro |
Victor Zverovich | 70a2317 | 2012-12-07 14:18:37 -0800 | [diff] [blame] | 73 | |
Victor Zverovich | 23063c3 | 2020-07-08 07:11:13 -0700 | [diff] [blame] | 74 | See the `documentation <https://fmt.dev>`_ for more details. |
Victor Zverovich | c7354b6 | 2013-01-21 10:11:59 -0800 | [diff] [blame] | 75 | |
Victor Zverovich | 58e53b4 | 2012-12-07 14:32:48 -0800 | [diff] [blame] | 76 | Examples |
| 77 | -------- |
Victor Zverovich | 70a2317 | 2012-12-07 14:18:37 -0800 | [diff] [blame] | 78 | |
Victor Zverovich | c2399cc | 2020-07-28 08:21:04 -0700 | [diff] [blame] | 79 | **Print to stdout** (`run <https://godbolt.org/z/Tevcjh>`_) |
Victor Zverovich | f02e410 | 2014-11-07 07:04:03 -0800 | [diff] [blame] | 80 | |
| 81 | .. code:: c++ |
Victor Zverovich | 58e53b4 | 2012-12-07 14:32:48 -0800 | [diff] [blame] | 82 | |
Victor Zverovich | 0b3a83f | 2020-06-20 05:37:58 -0700 | [diff] [blame] | 83 | #include <fmt/core.h> |
| 84 | |
| 85 | int main() { |
| 86 | fmt::print("Hello, world!\n"); |
| 87 | } |
Victor Zverovich | c50f94a | 2012-12-07 13:20:50 -0800 | [diff] [blame] | 88 | |
Victor Zverovich | 2a47a1e | 2020-08-01 12:00:01 -0700 | [diff] [blame] | 89 | **Format a string** (`run <https://godbolt.org/z/oK8h33>`_) |
Victor Zverovich | 4faec5a | 2020-07-05 06:41:51 -0700 | [diff] [blame] | 90 | |
| 91 | .. code:: c++ |
| 92 | |
| 93 | std::string s = fmt::format("The answer is {}.", 42); |
| 94 | // s == "The answer is 42." |
| 95 | |
Victor Zverovich | 0b6e7cc | 2020-08-03 21:51:48 -0700 | [diff] [blame] | 96 | **Format a string using positional arguments** (`run <https://godbolt.org/z/Yn7Txe>`_) |
Victor Zverovich | 0fa65cf | 2019-03-16 07:36:27 -0700 | [diff] [blame] | 97 | |
| 98 | .. code:: c++ |
| 99 | |
| 100 | std::string s = fmt::format("I'd rather be {1} than {0}.", "right", "happy"); |
Victor Zverovich | 9b392a6 | 2019-03-16 07:59:58 -0700 | [diff] [blame] | 101 | // s == "I'd rather be happy than right." |
Victor Zverovich | 0fa65cf | 2019-03-16 07:36:27 -0700 | [diff] [blame] | 102 | |
Victor Zverovich | 64e2da1 | 2020-07-28 08:35:28 -0700 | [diff] [blame] | 103 | **Print chrono durations** (`run <https://godbolt.org/z/K8s4Mc>`_) |
Victor Zverovich | 4faec5a | 2020-07-05 06:41:51 -0700 | [diff] [blame] | 104 | |
| 105 | .. code:: c++ |
| 106 | |
| 107 | #include <fmt/chrono.h> |
| 108 | |
| 109 | int main() { |
Victor Zverovich | 23063c3 | 2020-07-08 07:11:13 -0700 | [diff] [blame] | 110 | using namespace std::literals::chrono_literals; |
| 111 | fmt::print("Default format: {} {}\n", 42s, 100ms); |
| 112 | fmt::print("strftime-like format: {:%H:%M:%S}\n", 3h + 15min + 30s); |
Victor Zverovich | 4faec5a | 2020-07-05 06:41:51 -0700 | [diff] [blame] | 113 | } |
| 114 | |
Victor Zverovich | 0c1f4b5 | 2020-07-26 10:57:59 -0700 | [diff] [blame] | 115 | Output:: |
Victor Zverovich | 23063c3 | 2020-07-08 07:11:13 -0700 | [diff] [blame] | 116 | |
| 117 | Default format: 42s 100ms |
| 118 | strftime-like format: 03:15:30 |
Victor Zverovich | 4faec5a | 2020-07-05 06:41:51 -0700 | [diff] [blame] | 119 | |
Victor Zverovich | d7921d6 | 2020-08-06 19:41:17 -0700 | [diff] [blame] | 120 | **Print a container** (`run <https://godbolt.org/z/MjsY7c>`_) |
Victor Zverovich | c4ad94c | 2020-07-08 18:17:26 -0700 | [diff] [blame] | 121 | |
| 122 | .. code:: c++ |
| 123 | |
Victor Zverovich | c5adfc5 | 2020-07-09 06:21:02 -0700 | [diff] [blame] | 124 | #include <vector> |
Victor Zverovich | c4ad94c | 2020-07-08 18:17:26 -0700 | [diff] [blame] | 125 | #include <fmt/ranges.h> |
| 126 | |
| 127 | int main() { |
| 128 | std::vector<int> v = {1, 2, 3}; |
| 129 | fmt::print("{}\n", v); |
| 130 | } |
| 131 | |
Victor Zverovich | 0c1f4b5 | 2020-07-26 10:57:59 -0700 | [diff] [blame] | 132 | Output:: |
Victor Zverovich | c4ad94c | 2020-07-08 18:17:26 -0700 | [diff] [blame] | 133 | |
| 134 | {1, 2, 3} |
| 135 | |
Victor Zverovich | 0c1f4b5 | 2020-07-26 10:57:59 -0700 | [diff] [blame] | 136 | **Check a format string at compile time** |
Victor Zverovich | dba1ccc | 2017-11-10 07:38:51 -0800 | [diff] [blame] | 137 | |
| 138 | .. code:: c++ |
| 139 | |
Victor Zverovich | 1efdb2d | 2020-07-08 07:47:18 -0700 | [diff] [blame] | 140 | std::string s = fmt::format(FMT_STRING("{:d}"), "don't panic"); |
Victor Zverovich | dc69afa | 2020-07-08 07:44:36 -0700 | [diff] [blame] | 141 | |
Victor Zverovich | 1efdb2d | 2020-07-08 07:47:18 -0700 | [diff] [blame] | 142 | This gives a compile-time error because ``d`` is an invalid format specifier for |
| 143 | a string. |
Victor Zverovich | 1a236c8 | 2013-09-06 15:12:46 -0700 | [diff] [blame] | 144 | |
Victor Zverovich | 0c1f4b5 | 2020-07-26 10:57:59 -0700 | [diff] [blame] | 145 | **Write a file from a single thread** |
Victor Zverovich | 5f62954 | 2020-07-12 09:55:24 -0700 | [diff] [blame] | 146 | |
| 147 | .. code:: c++ |
| 148 | |
| 149 | #include <fmt/os.h> |
| 150 | |
| 151 | int main() { |
| 152 | auto out = fmt::output_file("guide.txt"); |
| 153 | out.print("Don't {}", "Panic"); |
| 154 | } |
| 155 | |
Victor Zverovich | 2f8fc29 | 2020-08-05 10:53:49 -0700 | [diff] [blame] | 156 | This can be `5 to 9 times faster than fprintf |
| 157 | <http://www.zverovich.net/2020/08/04/optimal-file-buffer-size.html>`_. |
Victor Zverovich | 5f62954 | 2020-07-12 09:55:24 -0700 | [diff] [blame] | 158 | |
Victor Zverovich | e2c8c45 | 2020-08-07 20:58:29 -0700 | [diff] [blame] | 159 | **Print with colors and text styles** |
Victor Zverovich | 0a7032a | 2020-07-26 08:14:18 -0700 | [diff] [blame] | 160 | |
| 161 | .. code:: c++ |
| 162 | |
| 163 | #include <fmt/color.h> |
| 164 | |
| 165 | int main() { |
| 166 | fmt::print(fg(fmt::color::crimson) | fmt::emphasis::bold, |
| 167 | "Hello, {}!\n", "world"); |
| 168 | fmt::print(fg(fmt::color::floral_white) | bg(fmt::color::slate_gray) | |
| 169 | fmt::emphasis::underline, "Hello, {}!\n", "мир"); |
| 170 | fmt::print(fg(fmt::color::steel_blue) | fmt::emphasis::italic, |
| 171 | "Hello, {}!\n", "世界"); |
| 172 | } |
| 173 | |
Victor Zverovich | 1378dda | 2020-08-08 18:01:56 -0700 | [diff] [blame] | 174 | Output on a modern terminal: |
Victor Zverovich | 0a7032a | 2020-07-26 08:14:18 -0700 | [diff] [blame] | 175 | |
| 176 | .. image:: https://user-images.githubusercontent.com/ |
Victor Zverovich | 63b422e | 2020-07-26 10:37:00 -0700 | [diff] [blame] | 177 | 576385/88485597-d312f600-cf2b-11ea-9cbe-61f535a86e28.png |
Victor Zverovich | 0a7032a | 2020-07-26 08:14:18 -0700 | [diff] [blame] | 178 | |
Victor Zverovich | fdd0149 | 2019-03-16 07:27:53 -0700 | [diff] [blame] | 179 | Benchmarks |
| 180 | ---------- |
| 181 | |
| 182 | Speed tests |
| 183 | ~~~~~~~~~~~ |
| 184 | |
| 185 | ================= ============= =========== |
| 186 | Library Method Run Time, s |
| 187 | ================= ============= =========== |
Victor Zverovich | 5916ff6 | 2019-12-07 10:12:15 -0800 | [diff] [blame] | 188 | libc printf 1.04 |
| 189 | libc++ std::ostream 3.05 |
Victor Zverovich | 95dfdc6 | 2019-12-07 10:12:56 -0800 | [diff] [blame] | 190 | {fmt} 6.1.1 fmt::print 0.75 |
Victor Zverovich | f4fcc5f | 2019-11-20 09:31:11 -0800 | [diff] [blame] | 191 | Boost Format 1.67 boost::format 7.24 |
Victor Zverovich | fdd0149 | 2019-03-16 07:27:53 -0700 | [diff] [blame] | 192 | Folly Format folly::format 2.23 |
| 193 | ================= ============= =========== |
| 194 | |
Victor Zverovich | f4fcc5f | 2019-11-20 09:31:11 -0800 | [diff] [blame] | 195 | {fmt} is the fastest of the benchmarked methods, ~35% faster than ``printf``. |
Victor Zverovich | fdd0149 | 2019-03-16 07:27:53 -0700 | [diff] [blame] | 196 | |
| 197 | The above results were generated by building ``tinyformat_test.cpp`` on macOS |
Victor Zverovich | c56cf3d | 2020-07-04 08:20:10 -0700 | [diff] [blame] | 198 | 10.14.6 with ``clang++ -O3 -DNDEBUG -DSPEED_TEST -DHAVE_FORMAT``, and taking the |
| 199 | best of three runs. In the test, the format string ``"%0.10f:%04d:%+g:%s:%p:%c:%%\n"`` |
Victor Zverovich | fdd0149 | 2019-03-16 07:27:53 -0700 | [diff] [blame] | 200 | or equivalent is filled 2,000,000 times with output sent to ``/dev/null``; for |
| 201 | further details refer to the `source |
| 202 | <https://github.com/fmtlib/format-benchmark/blob/master/tinyformat_test.cpp>`_. |
| 203 | |
Victor Zverovich | 5eb292a | 2020-10-11 09:57:21 -0700 | [diff] [blame] | 204 | {fmt} is up to 20-30x faster than ``std::ostringstream`` and ``sprintf`` on |
Victor Zverovich | c56cf3d | 2020-07-04 08:20:10 -0700 | [diff] [blame] | 205 | floating-point formatting (`dtoa-benchmark <https://github.com/fmtlib/dtoa-benchmark>`_) |
Victor Zverovich | 5eb292a | 2020-10-11 09:57:21 -0700 | [diff] [blame] | 206 | and faster than `double-conversion <https://github.com/google/double-conversion>`_ and |
| 207 | `ryu <https://github.com/ulfjack/ryu>`_: |
Victor Zverovich | 0a66e4c | 2019-03-24 11:37:07 -0700 | [diff] [blame] | 208 | |
Victor Zverovich | c142965 | 2020-07-08 13:34:47 -0700 | [diff] [blame] | 209 | .. image:: https://user-images.githubusercontent.com/576385/ |
Victor Zverovich | 5eb292a | 2020-10-11 09:57:21 -0700 | [diff] [blame] | 210 | 95684665-11719600-0ba8-11eb-8e5b-972ff4e49428.png |
| 211 | :target: https://fmt.dev/unknown_mac64_clang12.0.html |
Victor Zverovich | 0a66e4c | 2019-03-24 11:37:07 -0700 | [diff] [blame] | 212 | |
Victor Zverovich | fdd0149 | 2019-03-16 07:27:53 -0700 | [diff] [blame] | 213 | Compile time and code bloat |
| 214 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 215 | |
| 216 | The script `bloat-test.py |
| 217 | <https://github.com/fmtlib/format-benchmark/blob/master/bloat-test.py>`_ |
| 218 | from `format-benchmark <https://github.com/fmtlib/format-benchmark>`_ |
| 219 | tests compile time and code bloat for nontrivial projects. |
| 220 | It generates 100 translation units and uses ``printf()`` or its alternative |
| 221 | five times in each to simulate a medium sized project. The resulting |
| 222 | executable size and compile time (Apple LLVM version 8.1.0 (clang-802.0.42), |
| 223 | macOS Sierra, best of three) is shown in the following tables. |
| 224 | |
| 225 | **Optimized build (-O3)** |
| 226 | |
| 227 | ============= =============== ==================== ================== |
| 228 | Method Compile Time, s Executable size, KiB Stripped size, KiB |
| 229 | ============= =============== ==================== ================== |
| 230 | printf 2.6 29 26 |
| 231 | printf+string 16.4 29 26 |
| 232 | iostreams 31.1 59 55 |
| 233 | {fmt} 19.0 37 34 |
Victor Zverovich | fdd0149 | 2019-03-16 07:27:53 -0700 | [diff] [blame] | 234 | Boost Format 91.9 226 203 |
| 235 | Folly Format 115.7 101 88 |
| 236 | ============= =============== ==================== ================== |
| 237 | |
| 238 | As you can see, {fmt} has 60% less overhead in terms of resulting binary code |
| 239 | size compared to iostreams and comes pretty close to ``printf``. Boost Format |
| 240 | and Folly Format have the largest overheads. |
| 241 | |
| 242 | ``printf+string`` is the same as ``printf`` but with extra ``<string>`` |
| 243 | include to measure the overhead of the latter. |
| 244 | |
| 245 | **Non-optimized build** |
| 246 | |
| 247 | ============= =============== ==================== ================== |
| 248 | Method Compile Time, s Executable size, KiB Stripped size, KiB |
| 249 | ============= =============== ==================== ================== |
| 250 | printf 2.2 33 30 |
| 251 | printf+string 16.0 33 30 |
| 252 | iostreams 28.3 56 52 |
| 253 | {fmt} 18.2 59 50 |
Victor Zverovich | fdd0149 | 2019-03-16 07:27:53 -0700 | [diff] [blame] | 254 | Boost Format 54.1 365 303 |
| 255 | Folly Format 79.9 445 430 |
| 256 | ============= =============== ==================== ================== |
| 257 | |
| 258 | ``libc``, ``lib(std)c++`` and ``libfmt`` are all linked as shared libraries to |
Victor Zverovich | 6793ffc | 2019-11-20 09:33:59 -0800 | [diff] [blame] | 259 | compare formatting function overhead only. Boost Format is a |
| 260 | header-only library so it doesn't provide any linkage options. |
Victor Zverovich | fdd0149 | 2019-03-16 07:27:53 -0700 | [diff] [blame] | 261 | |
| 262 | Running the tests |
| 263 | ~~~~~~~~~~~~~~~~~ |
| 264 | |
| 265 | Please refer to `Building the library`__ for the instructions on how to build |
| 266 | the library and run the unit tests. |
| 267 | |
Victor Zverovich | 91bb3aa | 2019-05-17 15:42:00 -0700 | [diff] [blame] | 268 | __ https://fmt.dev/latest/usage.html#building-the-library |
Victor Zverovich | fdd0149 | 2019-03-16 07:27:53 -0700 | [diff] [blame] | 269 | |
| 270 | Benchmarks reside in a separate repository, |
| 271 | `format-benchmarks <https://github.com/fmtlib/format-benchmark>`_, |
| 272 | so to run the benchmarks you first need to clone this repository and |
| 273 | generate Makefiles with CMake:: |
| 274 | |
| 275 | $ git clone --recursive https://github.com/fmtlib/format-benchmark.git |
| 276 | $ cd format-benchmark |
| 277 | $ cmake . |
| 278 | |
| 279 | Then you can run the speed test:: |
| 280 | |
| 281 | $ make speed-test |
| 282 | |
| 283 | or the bloat test:: |
| 284 | |
| 285 | $ make bloat-test |
| 286 | |
Victor Zverovich | affa794 | 2014-01-30 11:16:27 -0800 | [diff] [blame] | 287 | Projects using this library |
| 288 | --------------------------- |
| 289 | |
Victor Zverovich | 71e705a | 2020-10-19 08:54:55 -0700 | [diff] [blame] | 290 | * `0 A.D. <https://play0ad.com/>`_: a free, open-source, cross-platform |
Victor Zverovich | 813732f | 2020-04-22 06:07:12 -0700 | [diff] [blame] | 291 | real-time strategy game |
Victor Zverovich | 38a7406 | 2015-02-06 13:46:19 -0800 | [diff] [blame] | 292 | |
Victor Zverovich | 73ec650 | 2014-10-12 14:18:17 -0700 | [diff] [blame] | 293 | * `AMPL/MP <https://github.com/ampl/mp>`_: |
Victor Zverovich | 71e705a | 2020-10-19 08:54:55 -0700 | [diff] [blame] | 294 | an open-source library for mathematical programming |
Victor Zverovich | 8603bd2 | 2020-06-11 17:25:20 -0700 | [diff] [blame] | 295 | |
| 296 | * `Aseprite <https://github.com/aseprite/aseprite>`_: |
Victor Zverovich | 71e705a | 2020-10-19 08:54:55 -0700 | [diff] [blame] | 297 | animated sprite editor & pixel art tool |
Victor Zverovich | 8603bd2 | 2020-06-11 17:25:20 -0700 | [diff] [blame] | 298 | |
Victor Zverovich | 71e705a | 2020-10-19 08:54:55 -0700 | [diff] [blame] | 299 | * `AvioBook <https://www.aviobook.aero/en>`_: a comprehensive aircraft |
Victor Zverovich | a084495 | 2018-11-28 17:28:27 -0800 | [diff] [blame] | 300 | operations suite |
Victor Zverovich | 29352af | 2018-12-01 08:19:20 -0800 | [diff] [blame] | 301 | |
Victor Zverovich | 71e705a | 2020-10-19 08:54:55 -0700 | [diff] [blame] | 302 | * `Blizzard Battle.net <https://battle.net/>`_: an online gaming platform |
| 303 | |
| 304 | * `Celestia <https://celestia.space/>`_: real-time 3D visualization of space |
Victor Zverovich | affa794 | 2014-01-30 11:16:27 -0800 | [diff] [blame] | 305 | |
Victor Zverovich | 71e705a | 2020-10-19 08:54:55 -0700 | [diff] [blame] | 306 | * `Ceph <https://ceph.com/>`_: a scalable distributed storage system |
Victor Zverovich | a084495 | 2018-11-28 17:28:27 -0800 | [diff] [blame] | 307 | |
Victor Zverovich | 71e705a | 2020-10-19 08:54:55 -0700 | [diff] [blame] | 308 | * `ccache <https://ccache.dev/>`_: a compiler cache |
Victor Zverovich | 58a8f2f | 2019-09-06 06:26:09 -0700 | [diff] [blame] | 309 | |
Victor Zverovich | 445f5d3 | 2020-07-08 07:36:07 -0700 | [diff] [blame] | 310 | * `ClickHouse <https://github.com/ClickHouse/ClickHouse>`_: analytical database |
| 311 | management system |
alexey-milovidov | 9047548 | 2020-07-05 15:57:04 +0300 | [diff] [blame] | 312 | |
Victor Zverovich | a084495 | 2018-11-28 17:28:27 -0800 | [diff] [blame] | 313 | * `CUAUV <http://cuauv.org/>`_: Cornell University's autonomous underwater |
| 314 | vehicle |
Victor Zverovich | 2bf59a9 | 2016-08-10 08:29:44 -0700 | [diff] [blame] | 315 | |
Victor Zverovich | 71e705a | 2020-10-19 08:54:55 -0700 | [diff] [blame] | 316 | * `Drake <https://drake.mit.edu/>`_: a planning, control, and analysis toolbox |
Victor Zverovich | 813732f | 2020-04-22 06:07:12 -0700 | [diff] [blame] | 317 | for nonlinear dynamical systems (MIT) |
| 318 | |
| 319 | * `Envoy <https://lyft.github.io/envoy/>`_: C++ L7 proxy and communication bus |
| 320 | (Lyft) |
| 321 | |
| 322 | * `FiveM <https://fivem.net/>`_: a modification framework for GTA V |
| 323 | |
Victor Zverovich | 8a11148 | 2020-04-22 06:16:07 -0700 | [diff] [blame] | 324 | * `Folly <https://github.com/facebook/folly>`_: Facebook open-source library |
| 325 | |
vitaut | 7e94fcb | 2015-12-03 08:09:53 -0800 | [diff] [blame] | 326 | * `HarpyWar/pvpgn <https://github.com/pvpgn/pvpgn-server>`_: |
Victor Zverovich | 8dbfd72 | 2014-06-28 19:17:13 -0700 | [diff] [blame] | 327 | Player vs Player Gaming Network with tweaks |
| 328 | |
Victor Zverovich | 71e705a | 2020-10-19 08:54:55 -0700 | [diff] [blame] | 329 | * `KBEngine <https://github.com/kbengine/kbengine>`_: an open-source MMOG server |
Victor Zverovich | c090569 | 2020-07-08 08:01:36 -0700 | [diff] [blame] | 330 | engine |
Victor Zverovich | 2938a92 | 2014-09-13 08:44:49 -0700 | [diff] [blame] | 331 | |
Victor Zverovich | 71e705a | 2020-10-19 08:54:55 -0700 | [diff] [blame] | 332 | * `Keypirinha <https://keypirinha.com/>`_: a semantic launcher for Windows |
Victor Zverovich | 090de29 | 2016-03-10 10:51:52 -0800 | [diff] [blame] | 333 | |
Victor Zverovich | 71e705a | 2020-10-19 08:54:55 -0700 | [diff] [blame] | 334 | * `Kodi <https://kodi.tv/>`_ (formerly xbmc): home theater software |
Victor Zverovich | a09f748 | 2018-01-27 17:47:41 -0800 | [diff] [blame] | 335 | |
Victor Zverovich | 71e705a | 2020-10-19 08:54:55 -0700 | [diff] [blame] | 336 | * `Knuth <https://kth.cash/>`_: high-performance Bitcoin full-node |
Fernando Pelliccioni | f230300 | 2020-05-19 22:08:32 -0300 | [diff] [blame] | 337 | |
Victor Zverovich | 8603bd2 | 2020-06-11 17:25:20 -0700 | [diff] [blame] | 338 | * `Microsoft Verona <https://github.com/microsoft/verona>`_: |
Victor Zverovich | 71e705a | 2020-10-19 08:54:55 -0700 | [diff] [blame] | 339 | research programming language for concurrent ownership |
Victor Zverovich | 73ec650 | 2014-10-12 14:18:17 -0700 | [diff] [blame] | 340 | |
Victor Zverovich | 71e705a | 2020-10-19 08:54:55 -0700 | [diff] [blame] | 341 | * `MongoDB <https://mongodb.com/>`_: distributed document database |
Billy Donahue | 1763d0e | 2019-04-12 12:47:21 -0400 | [diff] [blame] | 342 | |
Victor Zverovich | 71e705a | 2020-10-19 08:54:55 -0700 | [diff] [blame] | 343 | * `MongoDB Smasher <https://github.com/duckie/mongo_smasher>`_: a small tool to |
Victor Zverovich | c57029c | 2018-02-01 16:44:27 -0800 | [diff] [blame] | 344 | generate randomized datasets |
Victor Zverovich | 6e82084 | 2016-03-01 14:28:52 -0800 | [diff] [blame] | 345 | |
Victor Zverovich | 71e705a | 2020-10-19 08:54:55 -0700 | [diff] [blame] | 346 | * `OpenSpace <https://openspaceproject.com/>`_: an open-source |
Victor Zverovich | 813732f | 2020-04-22 06:07:12 -0700 | [diff] [blame] | 347 | astrovisualization framework |
Victor Zverovich | 1a7d0ba | 2018-02-02 19:10:25 -0800 | [diff] [blame] | 348 | |
谭九鼎 | cd2b990 | 2019-12-17 08:48:27 -0600 | [diff] [blame] | 349 | * `PenUltima Online (POL) <https://www.polserver.com/>`_: |
Victor Zverovich | 71e705a | 2020-10-19 08:54:55 -0700 | [diff] [blame] | 350 | an MMO server, compatible with most Ultima Online clients |
Victor Zverovich | 81dc04d | 2015-02-07 08:31:17 -0800 | [diff] [blame] | 351 | |
Victor Zverovich | 71e705a | 2020-10-19 08:54:55 -0700 | [diff] [blame] | 352 | * `PyTorch <https://github.com/pytorch/pytorch>`_: an open-source machine |
Victor Zverovich | 44b6584 | 2020-05-01 10:39:28 -0700 | [diff] [blame] | 353 | learning library |
| 354 | |
Victor Zverovich | 71e705a | 2020-10-19 08:54:55 -0700 | [diff] [blame] | 355 | * `quasardb <https://www.quasardb.net/>`_: a distributed, high-performance, |
Victor Zverovich | 1a7d0ba | 2018-02-02 19:10:25 -0800 | [diff] [blame] | 356 | associative database |
Victor Zverovich | 16985fd | 2020-08-09 08:56:51 -0700 | [diff] [blame] | 357 | |
Victor Zverovich | 71e705a | 2020-10-19 08:54:55 -0700 | [diff] [blame] | 358 | * `Quill <https://github.com/odygrd/quill>`_: asynchronous low-latency logging library |
Victor Zverovich | 001054c | 2015-04-27 07:02:15 -0700 | [diff] [blame] | 359 | |
Victor Zverovich | 71e705a | 2020-10-19 08:54:55 -0700 | [diff] [blame] | 360 | * `QKW <https://github.com/ravijanjam/qkw>`_: generalizing aliasing to simplify |
Victor Zverovich | d5b8002 | 2020-09-21 09:40:49 -0700 | [diff] [blame] | 361 | navigation, and executing complex multi-line terminal command sequences |
Ravi J | 821471e | 2020-09-21 11:39:07 -0500 | [diff] [blame] | 362 | |
Victor Zverovich | 71e705a | 2020-10-19 08:54:55 -0700 | [diff] [blame] | 363 | * `redis-cerberus <https://github.com/HunanTV/redis-cerberus>`_: a Redis cluster |
Victor Zverovich | a084495 | 2018-11-28 17:28:27 -0800 | [diff] [blame] | 364 | proxy |
Victor Zverovich | 42d8f5b | 2015-09-16 21:33:51 -0700 | [diff] [blame] | 365 | |
Victor Zverovich | 71e705a | 2020-10-19 08:54:55 -0700 | [diff] [blame] | 366 | * `redpanda <https://vectorized.io/redpanda>`_: a 10x faster Kafka® replacement |
Victor Zverovich | e371e8b | 2020-04-22 06:13:36 -0700 | [diff] [blame] | 367 | for mission critical systems written in C++ |
Alexander Gallego | 3670d5b | 2020-04-21 18:44:14 -0700 | [diff] [blame] | 368 | |
Victor Zverovich | 71e705a | 2020-10-19 08:54:55 -0700 | [diff] [blame] | 369 | * `rpclib <http://rpclib.net/>`_: a modern C++ msgpack-RPC server and client |
Victor Zverovich | b10ccb8 | 2018-12-05 06:42:33 -0800 | [diff] [blame] | 370 | library |
| 371 | |
Victor Zverovich | 813732f | 2020-04-22 06:07:12 -0700 | [diff] [blame] | 372 | * `Salesforce Analytics Cloud |
| 373 | <https://www.salesforce.com/analytics-cloud/overview/>`_: |
Victor Zverovich | 71e705a | 2020-10-19 08:54:55 -0700 | [diff] [blame] | 374 | business intelligence software |
Victor Zverovich | a23fbbb | 2014-12-02 12:54:12 -0800 | [diff] [blame] | 375 | |
Victor Zverovich | 71e705a | 2020-10-19 08:54:55 -0700 | [diff] [blame] | 376 | * `Scylla <https://www.scylladb.com/>`_: a Cassandra-compatible NoSQL data store |
Victor Zverovich | a084495 | 2018-11-28 17:28:27 -0800 | [diff] [blame] | 377 | that can handle 1 million transactions per second on a single server |
Victor Zverovich | 2bf59a9 | 2016-08-10 08:29:44 -0700 | [diff] [blame] | 378 | |
Victor Zverovich | 71e705a | 2020-10-19 08:54:55 -0700 | [diff] [blame] | 379 | * `Seastar <http://www.seastar-project.org/>`_: an advanced, open-source C++ |
Victor Zverovich | a084495 | 2018-11-28 17:28:27 -0800 | [diff] [blame] | 380 | framework for high-performance server applications on modern hardware |
Victor Zverovich | 2bf59a9 | 2016-08-10 08:29:44 -0700 | [diff] [blame] | 381 | |
Victor Zverovich | 71e705a | 2020-10-19 08:54:55 -0700 | [diff] [blame] | 382 | * `spdlog <https://github.com/gabime/spdlog>`_: super fast C++ logging library |
Victor Zverovich | 6e3d7d9 | 2014-12-08 06:15:31 -0800 | [diff] [blame] | 383 | |
Victor Zverovich | 71e705a | 2020-10-19 08:54:55 -0700 | [diff] [blame] | 384 | * `Stellar <https://www.stellar.org/>`_: financial platform |
Victor Zverovich | a12f496 | 2015-09-16 21:45:27 -0700 | [diff] [blame] | 385 | |
Victor Zverovich | 71e705a | 2020-10-19 08:54:55 -0700 | [diff] [blame] | 386 | * `Touch Surgery <https://www.touchsurgery.com/>`_: surgery simulator |
vitaut | 32fbc08 | 2015-08-08 18:58:25 -0700 | [diff] [blame] | 387 | |
Victor Zverovich | 71e705a | 2020-10-19 08:54:55 -0700 | [diff] [blame] | 388 | * `TrinityCore <https://github.com/TrinityCore/TrinityCore>`_: open-source |
Victor Zverovich | a084495 | 2018-11-28 17:28:27 -0800 | [diff] [blame] | 389 | MMORPG framework |
Victor Zverovich | ef5972e | 2015-03-17 19:43:47 -0700 | [diff] [blame] | 390 | |
Victor Zverovich | 71e705a | 2020-10-19 08:54:55 -0700 | [diff] [blame] | 391 | * `Windows Terminal <https://github.com/microsoft/terminal>`_: the new Windows |
| 392 | terminal |
Victor Zverovich | 9e2ad7c | 2020-04-21 15:47:04 -0700 | [diff] [blame] | 393 | |
Victor Zverovich | 2ed412f | 2019-09-06 13:03:14 -0700 | [diff] [blame] | 394 | `More... <https://github.com/search?q=fmtlib&type=Code>`_ |
Victor Zverovich | d930f69 | 2015-02-06 14:03:44 -0800 | [diff] [blame] | 395 | |
Victor Zverovich | 9d59057 | 2014-06-29 11:51:27 -0700 | [diff] [blame] | 396 | If you are aware of other projects using this library, please let me know |
Victor Zverovich | 73ec650 | 2014-10-12 14:18:17 -0700 | [diff] [blame] | 397 | by `email <mailto:victor.zverovich@gmail.com>`_ or by submitting an |
Victor Zverovich | e817bb9 | 2016-04-27 08:23:03 -0700 | [diff] [blame] | 398 | `issue <https://github.com/fmtlib/fmt/issues>`_. |
Victor Zverovich | affa794 | 2014-01-30 11:16:27 -0800 | [diff] [blame] | 399 | |
Victor Zverovich | 3e4d847 | 2012-12-07 15:33:27 -0800 | [diff] [blame] | 400 | Motivation |
| 401 | ---------- |
| 402 | |
| 403 | So why yet another formatting library? |
| 404 | |
| 405 | There are plenty of methods for doing this task, from standard ones like |
Victor Zverovich | 1428b34 | 2019-03-16 06:30:50 -0700 | [diff] [blame] | 406 | the printf family of function and iostreams to Boost Format and FastFormat |
Victor Zverovich | 5e5506f | 2019-03-12 06:08:18 -0700 | [diff] [blame] | 407 | libraries. The reason for creating a new library is that every existing |
Victor Zverovich | 3e4d847 | 2012-12-07 15:33:27 -0800 | [diff] [blame] | 408 | solution that I found either had serious issues or didn't provide |
| 409 | all the features I needed. |
| 410 | |
Victor Zverovich | a7f68dc | 2019-03-16 06:46:19 -0700 | [diff] [blame] | 411 | printf |
Victor Zverovich | 3e4d847 | 2012-12-07 15:33:27 -0800 | [diff] [blame] | 412 | ~~~~~~ |
| 413 | |
Victor Zverovich | a7f68dc | 2019-03-16 06:46:19 -0700 | [diff] [blame] | 414 | The good thing about ``printf`` is that it is pretty fast and readily available |
Victor Zverovich | e1ba41f | 2014-05-14 19:17:20 -0700 | [diff] [blame] | 415 | being a part of the C standard library. The main drawback is that it |
Victor Zverovich | ef39274 | 2019-03-16 06:47:18 -0700 | [diff] [blame] | 416 | doesn't support user-defined types. ``printf`` also has safety issues although |
Victor Zverovich | a7f68dc | 2019-03-16 06:46:19 -0700 | [diff] [blame] | 417 | they are somewhat mitigated with `__attribute__ ((format (printf, ...)) |
谭九鼎 | cd2b990 | 2019-12-17 08:48:27 -0600 | [diff] [blame] | 418 | <https://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html>`_ in GCC. |
Victor Zverovich | cb45829 | 2012-12-09 10:09:15 -0800 | [diff] [blame] | 419 | There is a POSIX extension that adds positional arguments required for |
vitaut | 7e94fcb | 2015-12-03 08:09:53 -0800 | [diff] [blame] | 420 | `i18n <https://en.wikipedia.org/wiki/Internationalization_and_localization>`_ |
Victor Zverovich | a7f68dc | 2019-03-16 06:46:19 -0700 | [diff] [blame] | 421 | to ``printf`` but it is not a part of C99 and may not be available on some |
Victor Zverovich | cb45829 | 2012-12-09 10:09:15 -0800 | [diff] [blame] | 422 | platforms. |
Victor Zverovich | 3e4d847 | 2012-12-07 15:33:27 -0800 | [diff] [blame] | 423 | |
Victor Zverovich | 1428b34 | 2019-03-16 06:30:50 -0700 | [diff] [blame] | 424 | iostreams |
Victor Zverovich | 3e4d847 | 2012-12-07 15:33:27 -0800 | [diff] [blame] | 425 | ~~~~~~~~~ |
| 426 | |
Victor Zverovich | 1428b34 | 2019-03-16 06:30:50 -0700 | [diff] [blame] | 427 | The main issue with iostreams is best illustrated with an example: |
Victor Zverovich | a8a536b | 2012-12-13 08:12:09 -0800 | [diff] [blame] | 428 | |
Victor Zverovich | f02e410 | 2014-11-07 07:04:03 -0800 | [diff] [blame] | 429 | .. code:: c++ |
Victor Zverovich | 3e4d847 | 2012-12-07 15:33:27 -0800 | [diff] [blame] | 430 | |
| 431 | std::cout << std::setprecision(2) << std::fixed << 1.23456 << "\n"; |
| 432 | |
Victor Zverovich | a8a536b | 2012-12-13 08:12:09 -0800 | [diff] [blame] | 433 | which is a lot of typing compared to printf: |
| 434 | |
Victor Zverovich | f02e410 | 2014-11-07 07:04:03 -0800 | [diff] [blame] | 435 | .. code:: c++ |
Victor Zverovich | 3e4d847 | 2012-12-07 15:33:27 -0800 | [diff] [blame] | 436 | |
| 437 | printf("%.2f\n", 1.23456); |
| 438 | |
Victor Zverovich | 1428b34 | 2019-03-16 06:30:50 -0700 | [diff] [blame] | 439 | Matthew Wilson, the author of FastFormat, called this "chevron hell". iostreams |
| 440 | don't support positional arguments by design. |
Victor Zverovich | 3e4d847 | 2012-12-07 15:33:27 -0800 | [diff] [blame] | 441 | |
Victor Zverovich | 1428b34 | 2019-03-16 06:30:50 -0700 | [diff] [blame] | 442 | The good part is that iostreams support user-defined types and are safe although |
Victor Zverovich | a7f68dc | 2019-03-16 06:46:19 -0700 | [diff] [blame] | 443 | error handling is awkward. |
Victor Zverovich | 3e4d847 | 2012-12-07 15:33:27 -0800 | [diff] [blame] | 444 | |
Victor Zverovich | a7f68dc | 2019-03-16 06:46:19 -0700 | [diff] [blame] | 445 | Boost Format |
| 446 | ~~~~~~~~~~~~ |
Victor Zverovich | 3e4d847 | 2012-12-07 15:33:27 -0800 | [diff] [blame] | 447 | |
Victor Zverovich | a7f68dc | 2019-03-16 06:46:19 -0700 | [diff] [blame] | 448 | This is a very powerful library which supports both ``printf``-like format |
| 449 | strings and positional arguments. Its main drawback is performance. According to |
Victor Zverovich | c090569 | 2020-07-08 08:01:36 -0700 | [diff] [blame] | 450 | various, benchmarks it is much slower than other methods considered here. Boost |
Victor Zverovich | a7f68dc | 2019-03-16 06:46:19 -0700 | [diff] [blame] | 451 | Format also has excessive build times and severe code bloat issues (see |
| 452 | `Benchmarks`_). |
Victor Zverovich | 3e4d847 | 2012-12-07 15:33:27 -0800 | [diff] [blame] | 453 | |
| 454 | FastFormat |
| 455 | ~~~~~~~~~~ |
| 456 | |
Victor Zverovich | c56cf3d | 2020-07-04 08:20:10 -0700 | [diff] [blame] | 457 | This is an interesting library which is fast, safe and has positional arguments. |
| 458 | However, it has significant limitations, citing its author: |
Victor Zverovich | 3e4d847 | 2012-12-07 15:33:27 -0800 | [diff] [blame] | 459 | |
| 460 | Three features that have no hope of being accommodated within the |
| 461 | current design are: |
| 462 | |
| 463 | * Leading zeros (or any other non-space padding) |
| 464 | * Octal/hexadecimal encoding |
| 465 | * Runtime width/alignment specification |
| 466 | |
Victor Zverovich | c56cf3d | 2020-07-04 08:20:10 -0700 | [diff] [blame] | 467 | It is also quite big and has a heavy dependency, STLSoft, which might be too |
| 468 | restrictive for using it in some projects. |
Victor Zverovich | 3e4d847 | 2012-12-07 15:33:27 -0800 | [diff] [blame] | 469 | |
Victor Zverovich | 3cea869 | 2012-12-24 21:31:05 -0800 | [diff] [blame] | 470 | Boost Spirit.Karma |
| 471 | ~~~~~~~~~~~~~~~~~~ |
| 472 | |
Victor Zverovich | a7f68dc | 2019-03-16 06:46:19 -0700 | [diff] [blame] | 473 | This is not really a formatting library but I decided to include it here for |
| 474 | completeness. As iostreams, it suffers from the problem of mixing verbatim text |
| 475 | with arguments. The library is pretty fast, but slower on integer formatting |
Victor Zverovich | c56cf3d | 2020-07-04 08:20:10 -0700 | [diff] [blame] | 476 | than ``fmt::format_to`` with format string compilation on Karma's own benchmark, |
| 477 | see `Converting a hundred million integers to strings per second |
| 478 | <http://www.zverovich.net/2020/06/13/fast-int-to-string-revisited.html>`_. |
Victor Zverovich | 8bbb0b4 | 2018-08-15 06:34:34 -0700 | [diff] [blame] | 479 | |
Victor Zverovich | faccb4c | 2012-12-12 07:44:41 -0800 | [diff] [blame] | 480 | License |
| 481 | ------- |
| 482 | |
Victor Zverovich | 972ffd3 | 2019-09-06 13:13:30 -0700 | [diff] [blame] | 483 | {fmt} is distributed under the MIT `license |
Victor Zverovich | e817bb9 | 2016-04-27 08:23:03 -0700 | [diff] [blame] | 484 | <https://github.com/fmtlib/fmt/blob/master/LICENSE.rst>`_. |
Victor Zverovich | e7c7b12 | 2013-01-14 06:43:31 -0800 | [diff] [blame] | 485 | |
Victor Zverovich | c56cf3d | 2020-07-04 08:20:10 -0700 | [diff] [blame] | 486 | Documentation License |
| 487 | --------------------- |
Victor Zverovich | e7c7b12 | 2013-01-14 06:43:31 -0800 | [diff] [blame] | 488 | |
Victor Zverovich | c56cf3d | 2020-07-04 08:20:10 -0700 | [diff] [blame] | 489 | The `Format String Syntax <https://fmt.dev/latest/syntax.html>`_ |
| 490 | section in the documentation is based on the one from Python `string module |
| 491 | documentation <https://docs.python.org/3/library/string.html#module-string>`_. |
| 492 | For this reason the documentation is distributed under the Python Software |
| 493 | Foundation license available in `doc/python-license.txt |
| 494 | <https://raw.github.com/fmtlib/fmt/master/doc/python-license.txt>`_. |
| 495 | It only applies if you distribute the documentation of {fmt}. |
| 496 | |
| 497 | Maintainers |
| 498 | ----------- |
Victor Zverovich | c50f94a | 2012-12-07 13:20:50 -0800 | [diff] [blame] | 499 | |
Victor Zverovich | fdd0149 | 2019-03-16 07:27:53 -0700 | [diff] [blame] | 500 | The {fmt} library is maintained by Victor Zverovich (`vitaut |
Victor Zverovich | 38b603a | 2018-01-20 17:12:43 -0800 | [diff] [blame] | 501 | <https://github.com/vitaut>`_) and Jonathan Müller (`foonathan |
| 502 | <https://github.com/foonathan>`_) with contributions from many other people. |
| 503 | See `Contributors <https://github.com/fmtlib/fmt/graphs/contributors>`_ and |
| 504 | `Releases <https://github.com/fmtlib/fmt/releases>`_ for some of the names. |
| 505 | Let us know if your contribution is not listed or mentioned incorrectly and |
| 506 | we'll make it right. |