You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Use f-strings instead of str.format within importlib #82874
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee='https://github.com/gpshead'closed_at=Nonecreated_at=<Date2019-11-05.06:20:17.309>labels= ['3.11', 'performance']
title='Use f-strings instead of str.format within importlib'updated_at=<Date2021-05-26.21:09:35.360>user='https://github.com/gpshead'
Status: Waiting until after the importlib.metadata and importlib.resources backports drop support for both Python 2.7 and 3.5 as keeping them in sync would be a pain for maintainers (per jaraco on our sprint importlib-any chat today)
I just have merged a change which makes many C-style formatting as fast as f-strings (bpo-28307) and am working on supporting more format codes (%d, %x, %f, etc). Using C-style formatting can be a good option if you want performance and backward compatibility. It was faster than str.format() even without that optimization.
New changeset f6fbdb9 by Jason R. Coombs in branch 'main': bpo-38693: Prefer f-strings in importlib.resources (importlib_resources 5.0.6). (GH-26387) f6fbdb9
New changeset 97b4576 by Miss Islington (bot) in branch '3.10': bpo-38693: Prefer f-strings in importlib.resources (importlib_resources 5.0.6). (GH-26387) (bpo-26389) 97b4576
Activity
gpshead commentedon Nov 5, 2019
importlib is full of str.format calls, modernizing it to use f-strings is a slight performance win and much more readable.
csabella commentedon May 23, 2020
Did you want this one to land in 3.9?
gpshead commentedon Oct 19, 2020
Status: Waiting until after the importlib.metadata and importlib.resources backports drop support for both Python 2.7 and 3.5 as keeping them in sync would be a pain for maintainers (per jaraco on our sprint importlib-any chat today)
FFY00 commentedon May 13, 2021
Both importlib_metadata and importlib_resources have dropped support for Python 2.7 and 3.5, this should now be unblocked.
serhiy-storchaka commentedon May 14, 2021
I just have merged a change which makes many C-style formatting as fast as f-strings (bpo-28307) and am working on supporting more format codes (%d, %x, %f, etc). Using C-style formatting can be a good option if you want performance and backward compatibility. It was faster than str.format() even without that optimization.
miss-islington commentedon May 26, 2021
New changeset e6c815d by Jason R. Coombs in branch 'main':
bpo-38693: importlib.metadata f-strings (GH-26383)
e6c815d
miss-islington commentedon May 26, 2021
New changeset 78a8428 by Miss Islington (bot) in branch '3.10':
bpo-38693: importlib.metadata f-strings (GH-26383)
78a8428
miss-islington commentedon May 26, 2021
New changeset f6fbdb9 by Jason R. Coombs in branch 'main':
bpo-38693: Prefer f-strings in importlib.resources (importlib_resources 5.0.6). (GH-26387)
f6fbdb9
jaraco commentedon May 26, 2021
New changeset 97b4576 by Miss Islington (bot) in branch '3.10':
bpo-38693: Prefer f-strings in importlib.resources (importlib_resources 5.0.6). (GH-26387) (bpo-26389)
97b4576
gpshead commentedon Oct 6, 2022
#17058 did this for
Lib/importlib/_bootstrap.pygpshead commentedon Oct 6, 2022
remaining things to consider (not all need to be converted):
gh-82874: Convert remaining importlib format uses to f-str. (#98005)
Merge branch 'main' into typewatch
pythongh-82874: Convert remaining importlib format uses to f-str. (py…
pythongh-82874: Convert remaining importlib format uses to f-str. (py…