tools-python icon indicating copy to clipboard operation
tools-python copied to clipboard

Changing the old-style f-string (str.format() ) to new style f-strings.

Open Yash-Varshney opened this issue 4 years ago • 3 comments

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.

Yash-Varshney avatar Jun 08 '20 14:06 Yash-Varshney

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.

Yash-Varshney avatar Oct 03 '20 19:10 Yash-Varshney

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.

RishabhBhatnagar avatar Oct 24 '20 06:10 RishabhBhatnagar

Python 3.6 is the earliest still supported version of Python.

zvr avatar Oct 24 '20 06:10 zvr

This has been implemented in the refactored version now found on main.

armintaenzertng avatar Mar 30 '23 08:03 armintaenzertng