requests icon indicating copy to clipboard operation
requests copied to clipboard

refactor: prefer f-strings to format where fits within black lengths

Open kkirsche opened this issue 3 years ago • 0 comments

Python added f-strings in version 3.6, with PEP 498. F-strings are a flexible and powerful way to format strings. They make the code shorter and more readable, since the code now looks more like the output.

F-Strings are also more performant than using .format (e.g. see F-String Speed Considerations, F-String Benchmarks for two quick examples) because the python runtime can insert the variables into the string while parsing rather than backtracking to insert them into the placeholders, reducing the number of times the lines need to be processed

kkirsche avatar Jun 29 '22 15:06 kkirsche