差分
このページの2つのバージョン間の差分を表示します。
両方とも前のリビジョン 前のリビジョン | 次のリビジョン両方とも次のリビジョン | ||
python:f-strings [2020/09/11 20:25] – ともやん | python:f-strings [2023/05/08 08:33] – [書式編集のパフォーマンス比較] ともやん | ||
---|---|---|---|
行 38: | 行 38: | ||
</ | </ | ||
===== 書式編集のパフォーマンス比較 ===== | ===== 書式編集のパフォーマンス比較 ===== | ||
- | < | + | < |
+ | <code python> | ||
+ | $ python | ||
+ | Python 3.11.3 (main, Apr 5 2023, 00:00:00) [GCC 13.0.1 20230401 (Red Hat 13.0.1-0)] on linux | ||
+ | Type " | ||
+ | >>> | ||
+ | >>> | ||
+ | ... f' | ||
+ | 0.23176945900195278 | ||
+ | >>> | ||
+ | ... '%s is %s.' % (name, age)""", | ||
+ | 0.22832379801548086 | ||
+ | >>> | ||
+ | ... '{} is {}.' | ||
+ | 0.42849745802232064 | ||
+ | >>> | ||
+ | ... '{0} is {1}.' | ||
+ | 0.5094511199858971 | ||
+ | >>> | ||
+ | </code> | ||
<code python> | <code python> | ||
$ python | $ python |