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
argparse: remove redundant len() #104273
Comments
hello @buraksaler! it is not clear from this issue what looking at the linked PR, I'm inferring you refer to the argparse module, where you suggest replacing 3 |
Justification: Calculating common subexpressions just once is a common optimization. I don't think benchmarking is needed. |
I guess I'm okay with the specific PR, but in general we discourage microoptimisations in cold code, especially if done without any kind of benchmarking. These cost reviewer time, can hurt readability and if poorly done run the risk of regressions. I certainly wouldn't welcome PRs doing CSE wherever possible for calls to len in the standard library. You'd need several millions of lines of help for this to add up to anything meaningful. |
Feature or enhancement
I decreased calling of redundant len() function.
Pitch
(Explain why this feature or enhancement should be implemented and how it would be used.
Add examples, if applicable.)
Previous discussion
Linked PRs
The text was updated successfully, but these errors were encountered: