-
-
Notifications
You must be signed in to change notification settings - Fork 290
Avoid performing **
operations on values greater than 1e5
#1610
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
Conversation
Pull Request Test Coverage Report for Build 2468595687
π - Coveralls |
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.
Thank you for working on this ! I thought about that issues a little and I was wondering about a time out with a really small threshold (0.01s?) and the possibility to relaunch with a flag if you really want the result. Knowing that something will take a long time to calculate is a NP problem, seeing it took longer than x is a P problem. How long does 9999 ** 9999
takes for exemple ? How long does any mathematical calculation actually takes ? I don't think we want to add a bunch of conditions like that for each possible formula. What do you think?
Oh I agree, I just didn't think we were likely to run into any additional cases. Exponents seemed like the only case that could blow up.
Interesting, I'm not aware of a means to interrupt a call like this, do you have a suggestion? |
A lot of things have a tendency to surprise us when pylint is ran on a lot of unexpected code π I don't have an example of calculation that would take a long time but I think it will always be possible to do so. Maybe it's time to open a cop/robber question on code golf stackexchange with one team trying to catch pathological cases and the other one trying to make the infer slow π ! But maybe it's enough to handle this case only.
Actually doing it crossplatform and multiprocessus compatible is not that easy. (I was thinking of |
Cool, I didn't know about Problems like this are fun, but, in the interest of expediency, I guess I was thinking a one-off special case would be enough of a "best efforts" basis. FWIW 1e4 values seem to |
I love the idea, but are we aware of a way to accomplish this on Windows? |
It seems you need to use multiprocess of threads so harder than what I thought it would be with |
@Pierre-Sassoulas i think it is a good idea to limit the time spent in inference process but i would like to hear @cdce8p opinion on this... |
I'm skeptical if it's truly worth the effort. My understanding is that canceling recursive calls above a threshold is comparatively easy. Any timeout based solution does add additional complexity, even if we can avoid threading / multiprocessing, which needs to be maintained. Additionally, it will make debugging more difficult and might even lead to non-deterministic results which in itself can be a nightmare. In the end we probably have to ask ourselves if it's worth it or if there are better / easier alternatives. For instance, I do like this PR. It will provide a speedup in some edge cases without adding much complexity. |
Description
Avoid actually calculating
**
operations on values greater than 1e5.Type of Changes
Related Issue
Closes pylint-dev/pylint#6745