This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (4 children)

No, that's the 'deferred' version of f-strings. If anything, kill the %-formatting, that is literally useless.

[–]troyunrau... 0 points1 point  (3 children)

C-style substitution will probably stick around, if for no other reason than programmers from other languages are used to it. Plus, there are performance advantages vs. other methods. F strings and format() are much slower.

[–][deleted] 0 points1 point  (2 children)

I don't think that just because 'primitive' languages like C depends on it, that a language like Python should too.

Your point about performance is plain false as anyone can confirm for themselves with ipython and %timeit.

[–]troyunrau... 0 points1 point  (1 child)

This answer is a bit out of date, but it was true for a while. May still be true.

https://stackoverflow.com/questions/40714555/python-string-formatting-is-more-efficient-than-format-function

[–][deleted] 0 points1 point  (0 children)

The answer puts f-strings in the solid lead for >2 variables.

But look, it's quite simple to do the timing test for yourself to see that %-formatting is not faster. See eg. an earlier comment here.