Python f-string benchmarks

Python 3.6 f-strings have been shown to be the fastest string formatting method in microbenchmarks by Python core dev Raymond Hettinger:

In relative speed factors, that’s:

  • f-string: 1.0
  • concatenate string: 1.33
  • join sequence of strings: 1.73
  • %s formatting operator: 2.40
  • .format() method: 3.62
  • Template() method: 11.48

The reason for this speedy performance was described by Python core dev Serhiy Storchaka: