-
-
Notifications
You must be signed in to change notification settings - Fork 275
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
Avoid expensive list/tuple multiplication operations #2228
Avoid expensive list/tuple multiplication operations #2228
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #2228 +/- ##
=======================================
Coverage 92.93% 92.93%
=======================================
Files 95 95
Lines 10921 10924 +3
=======================================
+ Hits 10149 10152 +3
Misses 772 772
Flags with carried forward coverage won't be shown. Click here to find out more.
|
astroid/protocols.py
Outdated
@@ -167,6 +167,9 @@ def _multiply_seq_by_int( | |||
context: InferenceContext, | |||
) -> _TupleListNodeT: | |||
node = self.__class__(parent=opnode) | |||
if isinstance(other.value, int) and other.value > 1e8: | |||
node.elts = [nodes.Const(NotImplemented)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be Uninferable instead of NotImplemented ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose that's better than implying there's one element in the list.
(cherry picked from commit 1a318a0)
Type of Changes
Description
Closes pylint-dev/pylint#8748
Similar approach to #1610, instead of adding this guard to
safe_infer
, since it seems better to catch this as close to the source as possible instead of all of the places that callinfer()
.