New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bpo-38693: Use f-strings instead of str.format() within importlib #17058
base: main
Are you sure you want to change the base?
Conversation
This is a small performance improvement, especially for one or two hot places such as _handle_fromlist() that are called a lot and the .format() method was being used just to join two strings with a dot. Otherwise it is merely a readability improvement. This could be backported to 3.8 as it changes no functionality. I kept `_ERR_MSG` as an attribute in `importlib._bootstrap` and `imp` as I wasn't sure if there were other things in the world that might refer to those. They're private and could go away in 3.9 but should not within 3.8 just in case.
It belongs with a later _ERR_MSG cleanup.
I think this is generally a good idea, and all of the changes look correct.
However, I'm not sure I'd remove the use of _ERR_MSG, since it is used outside of this file. Either that, or remove it in Lib/imp.py, too (the only other place it's used).
I'm also not sure what value is added by _ERR_MSG_PREFIX. It doesn't seem to be used anywhere. I'd just roll it into _ERR_MSG, if it's being kept.
|
When you're done making the requested changes, leave the comment: |
@gpshead, please take a look at the review comments. Thanks! |
This is a small performance improvement, especially for one or two hot
places such as
_handle_fromlist()
that are called a lot and thestr.format()
method was being used just to join two strings with a'.'
.Otherwise it is merely a readability improvement.
This could be backported to 3.8 as it does not change any logic.
I kept
_ERR_MSG
as an attribute inimportlib._bootstrap
andimp
as I wasn't sure if there were other things in the world that might
refer to those. They're private and could go away in 3.9 but should
not within 3.8 just in case.
https://bugs.python.org/issue38693
The text was updated successfully, but these errors were encountered: