tools-python
tools-python copied to clipboard
Changing the old-style f-string (str.format() ) to new style f-strings.
The f-strings used in the code are very old and quite verbose when you are dealing with multiple parameters and longer strings. Python3.6 introduced a new style f-string which are not only easy to use but also easily readable and faster than the old python2.6 one.
This issue is currently paused and will be a part of a bigger project in which we need to halt v2.x of python and completely update the whole repo to work with v3 and above of python.
Can you provide some benchmarks to prove the efficiency of fstrings over str.format? Comparing fstrings with str.format of python2.7 won't be a fair comparison as many of the libraries in python3.x were rewritten in C to improve their runtime.
How does fstrings compare to str.format of python 3.x? If the difference is not significant, we can be better off without any modifications.
One more problem I can see with the replacement is that In order to provide backward compatibility to python versions < 3.6, we will be required to import functions from __future__ which will be costlier than the overhead(if any) of using str.format.
Python 3.6 is the earliest still supported version of Python.
This has been implemented in the refactored version now found on main.