Would there be any interest in a mass-conversion of cpython/Lib/ to f-strings?

I originally wanted to post in https://discuss.python.org/c/core-dev, but found the existing posts too formal/intimidating.

As the title says - would there be any interest in a mass-conversion of cpython/Lib/ to f-strings? I see a lot of format calls, and there might be some other occurences which take on different forms.

It’d make things more readable, and from various sources online, f-strings are usually faster.

Just wanted to gauge interest before I start working on it. I also am not sure if a mass-conversion in a single issue is desired, or if I should be doing it per module or package.

See https://bugs.python.org/issue38351 for some prior discussion on this (keyword “stdlib” but the whole discussion is pretty informative).

Also, https://bugs.python.org/issue36249 for another recent attempt at this idea.

1 Like

Thank you for digging the prior art up - it did not occur to me to search the issue tracker.

There are a lot of good points in those two issues, I’m definitely convinced it’s not really worth the effort. Namely the fact that it would pollute git history.

Would changing everything to f-strings adversely affect the profile-guided optimisation for %-style formatting? Or is there enough in the test suite to not be an issue?

Also, the git blame argument is weakened by the --ignore-revs feature of Git 2.23 (doc), as this allows you to version a file which stores undesired commits. Once GitHub supports this, I suspect style and formatting changes will be more acceptable.

1 Like