I'm afraid that it will be deprecated during the next Python versions

Don't be, str.format does not appear (nor has a reason) to be leaving any time soon, the PEP that introduced fprefixed-strings even states in its Abstract:

This PEP does not propose to remove or deprecate any of the existing string formatting mechanisms.

Formatted strings were introduced to address some of the shortcomings other methods for formatting strings had; not to throw the old methods away and force god-knows how many projects to use f-string's if they want their code to work for Python 3.6+.


As for the performance of these, it seems my initial suspicion that they might be slower is wrong, f-strings seem to easily outperform their .format counterparts:

➜ cpython git:(master) ./python -m timeit -s "a = 'test'" "f'formatting a string {a}'"
500000 loops, best of 5: 628 nsec per loop
➜ cpython git:(master) ./python -m timeit "'formatting a string {a}'.format(a='test')"
100000 loops, best of 5: 2.03 usec per loop

These were done against the master branch of the CPython repository as of this writing; they are definitely subject to change:

  • f-strings, as a new feature, might have possible optimizations
  • Optimizations to CPython might make .format faster (e.g Speedup method calls 1.2x)

But really, don't worry about speed so much, worry about what is more readable to you and to others.

In many cases, that's going to be f-strings, but there's some cases where format is better.

Answer from Dimitris Fasarakis Hilliard on Stack Overflow
Top answer
1 of 6
107

I'm afraid that it will be deprecated during the next Python versions

Don't be, str.format does not appear (nor has a reason) to be leaving any time soon, the PEP that introduced fprefixed-strings even states in its Abstract:

This PEP does not propose to remove or deprecate any of the existing string formatting mechanisms.

Formatted strings were introduced to address some of the shortcomings other methods for formatting strings had; not to throw the old methods away and force god-knows how many projects to use f-string's if they want their code to work for Python 3.6+.


As for the performance of these, it seems my initial suspicion that they might be slower is wrong, f-strings seem to easily outperform their .format counterparts:

➜ cpython git:(master) ./python -m timeit -s "a = 'test'" "f'formatting a string {a}'"
500000 loops, best of 5: 628 nsec per loop
➜ cpython git:(master) ./python -m timeit "'formatting a string {a}'.format(a='test')"
100000 loops, best of 5: 2.03 usec per loop

These were done against the master branch of the CPython repository as of this writing; they are definitely subject to change:

  • f-strings, as a new feature, might have possible optimizations
  • Optimizations to CPython might make .format faster (e.g Speedup method calls 1.2x)

But really, don't worry about speed so much, worry about what is more readable to you and to others.

In many cases, that's going to be f-strings, but there's some cases where format is better.

2 of 6
42

To build on Jim's answer and address your performance concern, I used python's dis module to compare the bytecode instructions for two syntactically different, but functionally equivalent functions.

import dis

def f1():
    a = "test"
    return f"{a}"

def f2():
    return "{a}".format(a='test')

print(dis.dis(f1))
print(dis.dis(f2))

The result of which is:

 11           0 LOAD_CONST               1 ('test')
              2 STORE_FAST               0 (a)

 12           4 LOAD_FAST                0 (a)
              6 FORMAT_VALUE             0
              8 RETURN_VALUE
None
 15           0 LOAD_CONST               1 ('{a}')
              2 LOAD_ATTR                0 (format)
              4 LOAD_CONST               2 ('test')
              6 LOAD_CONST               3 (('a',))
              8 CALL_FUNCTION_KW         1
             10 RETURN_VALUE
None

One can see that the f-string handles the formatting without attribute or function calls, which can impose type checking and memory overhead. According to timeit this results in a roughly 3x performance gain (for my specific functions)

>>> timeit.timeit('f1()', 'from __main__ import f1', number=100000)
0.012325852433775708
>>> timeit.timeit('f2()', 'from __main__ import f2', number=100000)
0.036395029920726074
Discussions

python - Which one? f string or using format in python3 - Stack Overflow
Some times when I used F string for Directory and file path I got some errors but there were no problem with using format. ... Better might be subjective, but the realpython website has a nice arcticle on why you should use one or the other. realpython.com/python-f-strings . More on stackoverflow.com
🌐 stackoverflow.com
What's better to use? (%), (f"string") or (.format())?
There's no rule, it's always about what you find the most readable. In almost all cases, f-strings will most likely be the winner. There is a reason they were introduced. More on reddit.com
🌐 r/learnpython
51
49
November 25, 2024
str.format() vs f"abc{my_var}" ?
F-strings are more readable and faster, but .format is backwards compatible with earlier python versions More on reddit.com
🌐 r/Python
32
2
July 13, 2018
python - String formatting: % vs. .format vs. f-string literal - Stack Overflow
There are various string formatting methods: Python More on stackoverflow.com
🌐 stackoverflow.com
🌐
Real Python
realpython.com › python-f-strings
Python's F-String for String Interpolation and Formatting – Real Python
November 30, 2024 - Python's f-strings provide a readable way to interpolate and format strings. They're readable, concise, and less prone to error than traditional string interpolation and formatting tools, such as the .format() method and the modulo operator ...
🌐
W3Schools
w3schools.com › python › python_string_formatting.asp
Python String Formatting
Before Python 3.6 we had to use the format() method. ... F-string allows you to format selected parts of a string.
🌐
LinkedIn
linkedin.com › pulse › format-vs-f-string-akhilesh-singh
format() vs f-String
April 6, 2023 - In conclusion, f-strings are faster than str.format() because they are evaluated at a phase that is closer to compile-time within Python's interpretation process, which reduces the amount of work that needs to be done at runtime.
🌐
Medium
medium.com › @DahlitzF › pythons-f-strings-vs-str-e22995cefef6
Python’s f-strings vs. str()
December 26, 2018 - A few months ago I’ve seen a tweet from a Python learner with a code snippet containing f-strings. I asked, why she’s not using format() . She answered, that this is the new way of formatting strings. I was curious about it as I didn’t hear about it before.
🌐
DataCamp
datacamp.com › tutorial › python-f-string
Python f-string: A Complete Guide | DataCamp
December 3, 2024 - F-strings are string literals prefixed ... protocol. Unlike traditional string formatting methods, f-strings provide a more straightforward and readable way to embed Python expressions directly within string literals....
Find elsewhere
🌐
Medium
sinhassatyam.medium.com › python-string-formatting-f-strings-vs-format-vs-aa97693b7244
⚡ Python String Formatting: F-strings vs .format() vs % | by Satyam Sinha | Medium
December 1, 2025 - F-strings are compiled into a highly efficient sequence of operations that load constant strings, evaluate expressions, and concatenate the results directly. The parsing overhead happens at compile time, not at runtime. When the compiler sees f"val: {x}", it generates code to: load the constant parts, evaluate x, format it, and then join them. # Until Python3.11 then modified in Python3.12+ # Bytecode for f"Value: {value:.2f}" (simplified) 2 0 LOAD_CONST 1 ('Value: ') 2 LOAD_NAME 0 (value) 4 FORMAT_VALUE 0 (FVC_NONE) 6 BUILD_STRING 2 # Since Python3.12 PI = 3.14159 dis.dis(lambda: f"pi value:{
🌐
Stack Overflow
stackoverflow.com › questions › 61368640 › which-one-f-string-or-using-format-in-python3
python - Which one? f string or using format in python3 - Stack Overflow
format would remain the only option in certain dynamic settings (consider that "This is for {}".format is a bound method like any other) and for backwards compatibility, but all things being equal, prefer an f-string.
🌐
Reddit
reddit.com › r/learnpython › what's better to use? (%), (f"string") or (.format())?
r/learnpython on Reddit: What's better to use? (%), (f"string") or (.format())?
November 25, 2024 -

I was trying to make a, silly program in which you can do some random things. I used arguments (%)in the past, but it's a bit hard to write like the identification of the variable, like there is so much types (%s, %f, %2f, %d, %g, %e...) and I want to take the easiest to write or the easiest to debug.

here are some examples of using each one:

  using (%):
name = "Imaginary_Morning"
age = 13
print("This profile is called %s and it has %d years old." % (name, age))
  
using (f"string"):
name = "Imaginary_Morning"
age = 13
print(f"This profile is called {name} and it has {age} years old.")

  using (.format()):
name = "Imaginary_Morning"
age = 13
print("This profile is called {} and it has {} years old.".format(name, age))
🌐
GeeksforGeeks
geeksforgeeks.org › formatted-string-literals-f-strings-python
f-strings in Python - GeeksforGeeks
June 19, 2024 - To create an f-string, prefix the ... way that you would with str.format(). F-strings provide a concise and convenient way to embed Python expressions inside string literals for formatting....
🌐
ZetCode
zetcode.com › python › fstring
Python f-string - formatting strings in Python with f-string
May 11, 2025 - Python f-string is a powerful and flexible string formatting method introduced in Python 3.6. Unlike older formatting techniques such as %-based formatting and str.format(), f-strings are faster, more readable, and less prone to errors.
🌐
Reddit
reddit.com › r/python › str.format() vs f"abc{my_var}" ?
r/Python on Reddit: str.format() vs f"abc{my_var}" ?
July 13, 2018 -

Hey settle an argument with my and my friend. We're working on a project together and he keeps suggesting str.format() and I keep persisting on the f"{}" syntax.

which is "best" ? (we're not doing intensive string operations)

🌐
Cybrosys Technologies
cybrosys.com › odoo blogs
Comparison Between Python's F-strings & Traditional String Formatting
October 10, 2023 - in this comprehensive article, we will dive deep into the power and simplicity of f-strings, a modern string formatting technique introduced in Python 3.6.
Top answer
1 of 16
994

To answer your first question... .format just seems more sophisticated in many ways. An annoying thing about % is also how it can either take a variable or a tuple. You'd think the following would always work:

"Hello %s" % name

yet, if name happens to be (1, 2, 3), it will throw a TypeError. To guarantee that it always prints, you'd need to do

"Hello %s" % (name,)   # supply the single argument as a single-item tuple

which is just ugly. .format doesn't have those issues. Also in the second example you gave, the .format example is much cleaner looking.

Only use it for backwards compatibility with Python 2.5.


To answer your second question, string formatting happens at the same time as any other operation - when the string formatting expression is evaluated. And Python, not being a lazy language, evaluates expressions before calling functions, so the expression log.debug("some debug info: %s" % some_info) will first evaluate the string to, e.g. "some debug info: roflcopters are active", then that string will be passed to log.debug().

2 of 16
320

Something that the modulo operator ( % ) can't do, afaik:

tu = (12,45,22222,103,6)
print '{0} {2} {1} {2} {3} {2} {4} {2}'.format(*tu)

result

12 22222 45 22222 103 22222 6 22222

Very useful.

Another point: format(), being a function, can be used as an argument in other functions:

li = [12,45,78,784,2,69,1254,4785,984]
print map('the number is {}'.format,li)   

print

from datetime import datetime,timedelta

once_upon_a_time = datetime(2010, 7, 1, 12, 0, 0)
delta = timedelta(days=13, hours=8,  minutes=20)

gen =(once_upon_a_time +x*delta for x in xrange(20))

print '\n'.join(map('{:%Y-%m-%d %H:%M:%S}'.format, gen))

Results in:

['the number is 12', 'the number is 45', 'the number is 78', 'the number is 784', 'the number is 2', 'the number is 69', 'the number is 1254', 'the number is 4785', 'the number is 984']

2010-07-01 12:00:00
2010-07-14 20:20:00
2010-07-28 04:40:00
2010-08-10 13:00:00
2010-08-23 21:20:00
2010-09-06 05:40:00
2010-09-19 14:00:00
2010-10-02 22:20:00
2010-10-16 06:40:00
2010-10-29 15:00:00
2010-11-11 23:20:00
2010-11-25 07:40:00
2010-12-08 16:00:00
2010-12-22 00:20:00
2011-01-04 08:40:00
2011-01-17 17:00:00
2011-01-31 01:20:00
2011-02-13 09:40:00
2011-02-26 18:00:00
2011-03-12 02:20:00
🌐
Python
peps.python.org › pep-0498
PEP 498 – Literal String Interpolation | peps.python.org
These include %-formatting [1], str.format() [2], and string.Template [3]. Each of these methods have their advantages, but in addition have disadvantages that make them cumbersome to use in practice. This PEP proposed to add a new string formatting mechanism: Literal String Interpolation. In this PEP, such strings will be referred to as “f-strings”, taken from the leading character used to denote such strings, and standing for “formatted strings”.
🌐
Linuxize
linuxize.com › home › python › python f-strings: string formatting in python 3
Python f-Strings: String Formatting in Python 3 | Linuxize
March 14, 2026 - What is the difference between f-strings and str.format()? f-strings are evaluated at runtime and embed expressions inline. str.format() uses positional or keyword placeholders and is slightly more verbose. f-strings are generally faster and ...
🌐
Bentley
cissandbox.bentley.edu › sandbox › wp-content › uploads › 2022-02-10-Documentation-on-f-strings-Updated.pdf pdf
A Guide to Formatting with f-strings in Python - CIS Sandbox
string. The letter 'f' also indicates that these strings are used for formatting. Although there are · other ways for formatting strings, the Zen of Python states that simple is better than complex
🌐
Towards Data Science
towardsdatascience.com › home › latest › introducing f-strings - the best option for string formatting in python
Introducing f-Strings - The Best Option for String Formatting in Python | Towards Data Science
January 26, 2025 - In a nutshell, f-Strings provide a cleaner and easier to manage way for formatting strings. Plus, they are a lot faster. You should use them whenever possible if you have access to Python 3.6 or a newer version.
🌐
Real Python
realpython.com › python-string-formatting
Python String Formatting: Available Tools and Their Features – Real Python
December 1, 2024 - While f-strings are more readable and efficient compared to .format() and the % operator, the .format() method supports lazy evaluation. To get the most out of this tutorial, you should be familiar with Python’s string data type and the available string interpolation tools.