May-20-2020, 03:20 PM
(May-20-2020, 02:40 PM)perfringo Wrote: I think that using built-in any() is even more efficient approach.nope, it's not
from timeit import timeit print(timeit("any(11==item for item in [11, 22, 33, 44, 55])")) print(timeit("11 in [11, 22, 33, 44, 55]")) print(timeit("any(55==item for item in [11, 22, 33, 44, 55])")) print(timeit("55 in [11, 22, 33, 44, 55]"))
Output:0.4314083050001045
0.022730736999847068
0.6241739300000972
0.076374732999966
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs