Closed changeling closed 5 years ago
On a side-note, in addition to readability advantages, f-strings turn out to be significantly better for performance. Out of curiosity, I benchmarked the various string-representation approaches, and f-strings are a clear winner. In the following, 'simple' refers to a bare string without any expressions, and the rest should be self-explanatory. I used timeit and ran 1,000,000 iterations last night, with the default seconds
for time unit:
simple f-string: 144.56685653899999
simple string: 128.51768768099998
f-string expressions: 414.141036833
printf style: 655.51534457
concatentaion: 804.0907651130001
.format() style: 874.8606495869999
using Template(): 6838.884037724
Note that in this PR, I've avoided converting 'simple' string statements, though the difference in performance is negligible.
Interesting data. I'll review your patch shortly, but I have some pending changes I'd like to finish first
…ent.
Changed to f-string formatting throughout for readability and performance. Changed a few instances of single-quoting ' to double-quotes " in to_json returns.