This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: inspect module points that could be using f-String
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.11, Python 3.10, Python 3.9, Python 3.8
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: Leonardofreua, ammar2, eric.smith
Priority: normal Keywords: patch

Created on 2021-07-12 18:34 by Leonardofreua, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 27100 closed Leonardofreua, 2021-07-12 18:41
Messages (6)
msg397343 - (view) Author: Leonardo Freua (Leonardofreua) * Date: 2021-07-12 18:34
There are some points in inspect module (I counted 48 since version 3.7) that could be using f-String formatting instead of format().

Changing these points will improve code readability, it will also decrease the complexity at these points and not to mention the fact that f-String formatting has better performance.

Obs.: Many other points could receive this improvement in other modules. This would provide the improvements I mentioned earlier, especially in older snippets of code.
msg397345 - (view) Author: Ammar Askar (ammar2) * (Python committer) Date: 2021-07-12 18:49
As per https://bugs.python.org/issue36249 and https://bugs.python.org/issue38351

We don't generally do large-scale changes that are mostly formatting based. We would prefer that these sort of improvements happen when someone happens to be touching that code anyway unless there is a demonstrable improvement from them.
msg397347 - (view) Author: Leonardo Freua (Leonardofreua) * Date: 2021-07-12 18:58
Understood. Anyway, it was good to try to help at this point.
msg397348 - (view) Author: Ammar Askar (ammar2) * (Python committer) Date: 2021-07-12 19:02
Thanks for trying to help Leonardo! You might consider looking for easy issues on the bug tracker or reviewing open pull requests to help. Definitely take a look at the dev guide :) https://cpython-devguide.readthedocs.io/fixingissues/
msg397349 - (view) Author: Leonardo Freua (Leonardofreua) * Date: 2021-07-12 19:05
Thanks, Ammar. I'll look.
msg397351 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2021-07-12 19:31
Yes, thank you Leonardo!

There are probably places in the stdlib where changing to f-strings would be a performance improvement. Of course finding those places is the challenge!
History
Date User Action Args
2022-04-11 14:59:47adminsetgithub: 88778
2021-07-12 19:31:52eric.smithsetnosy: + eric.smith
messages: + msg397351
2021-07-12 19:05:50Leonardofreuasetmessages: + msg397349
2021-07-12 19:02:35ammar2setstatus: open -> closed
resolution: rejected
messages: + msg397348

stage: patch review -> resolved
2021-07-12 18:58:42Leonardofreuasetmessages: + msg397347
2021-07-12 18:49:36ammar2setnosy: + ammar2
messages: + msg397345
2021-07-12 18:41:47Leonardofreuasetkeywords: + patch
stage: patch review
pull_requests: + pull_request25648
2021-07-12 18:34:00Leonardofreuacreate