pantsbuild / pants

The Pants Build System
https://www.pantsbuild.org
Apache License 2.0
3.33k stars 637 forks source link

convert format string literals to python 3 f-strings #7075

Closed cosmicexplorer closed 4 years ago

cosmicexplorer commented 5 years ago

Python 3 describes a more hygienic form of string templating known as f-strings. This is also more performant, some of which is described in this blog post. This seems like something that can be done incrementally once pants supports python 3 -- it's not clear if there are any cases where this is a big perf win yet, but I suspect they do exist in this codebase.

cosmicexplorer commented 5 years ago

We would probably need to have some form of benchmarking harness set up that I don't think we currently have in order to evaluate potential perf bumps like this (and if this did exist, it would be a great way to convince people that the migration to python 3 is really deeply worth spending more time on).

Eric-Arellano commented 5 years ago

I was planning on writing a script that automates the conversion. Beyond perf gains, it's simply more readable and concise.

Script will be how I've written scripts for things like converting set() to set comprehensions, i.e. script will generate the proposed change and then human still has to review it and sign off on it. Should help to catch edge cases.

Eric-Arellano commented 4 years ago

FYI @asherf found https://github.com/ikamensh/flynt to automate this all!

Eric-Arellano commented 4 years ago

This has been mostly done thanks to several PRs from Asher.