You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Greetings!
I noticed that method factors referred a StackOverflow post, while a recent comment to it mentioned that using 'if not n % i' instead of 'if n % i == 0' can speed up for 20-30%.
I'm trying to learn the usefulness of such small updates on StackOverflow. Would this comment help improve your code? I understand that such speedup might not be that helpful in real life situation. In that case, do you think this comment can help promote future projects (for example, when the code were reused somewhere else)?
I'll really appreciate it if you could kindly give me some feedback or suggestions. Thank you very much for your time.
Have a nice day!
The text was updated successfully, but these errors were encountered:
I contributed to this code base over 6 years ago. I don't recall where there's a check for n being a factor of i but I can't imagine it is a very significant portion of the runtime. And personally the 'if not n%i' may be faster, but it's not to me intuitive what it's doing, where I've seen 'if n%i == 0' I know exactly what it's doing the instant I see it. Readability counts.
Unless there's a dramatic use of factorization I'd guess it's probably not worth the effort. And if you're looking at doing something like that a lot in python then you're probably better off using a numerical library such as numpy.
Greetings!
I noticed that method factors referred a StackOverflow post, while a recent comment to it mentioned that using 'if not n % i' instead of 'if n % i == 0' can speed up for 20-30%.
I'm trying to learn the usefulness of such small updates on StackOverflow. Would this comment help improve your code? I understand that such speedup might not be that helpful in real life situation. In that case, do you think this comment can help promote future projects (for example, when the code were reused somewhere else)?
I'll really appreciate it if you could kindly give me some feedback or suggestions. Thank you very much for your time.
Have a nice day!
The text was updated successfully, but these errors were encountered: