[clang] [clang][Python] Use fstrings instead of string concatenations (PR #173861)

Vlad Serebrennikov via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 30 01:32:48 PST 2025


Endilll wrote:

> Fstrings provide a considerable performance increase over % and str.format(), to my knowledge (% must perform type checks, fstrings are optimised due to being core grammar features, and avoid additional function calls unlike % and str.format()).

None of the f-string introduced in this PR are on a hot path: they are either in `__repr__` or on error handling paths.

> I personally think being able to read the string with the interpolated variables at site is simpler than tracking them in order of arguments.

When this is a concern we can use named placeholders. I still don't see the need to interleave parts of the string with expressions.

https://github.com/llvm/llvm-project/pull/173861


More information about the cfe-commits mailing list