KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have a very long loop, and I would like to check the status every N iterations, in my specific case I have a loop of 10 million elements and I want to print a short report every millionth iteration. So, currently I am doing just (n is the iteration counter): if (n % 1000000==0): print('Progress report...') but I am worried I am slowing down the process by computing the modulus at each iteration, as one iteration lasts just few milliseconds. Is there a better way to do this? Or shouldn't I worry at all about the modulus operation?
Tags (comma-separated)
Save Edits
Cancel