list comparison vs integer comparison, which is more efficient?

Christian Gollwitzer auriocus at gmx.de
Sun Jan 4 13:22:18 CET 2015


Am 04.01.15 um 13:17 schrieb austin aigbe:
> However, it took a shorter time (0.004s) with 24 function calls than
your code (0.005s) which took just 13 function calls to execute.

> Why is this?

These times are way too short for conclusive results. Typically, the OS 
timer operates with a millisecond resolution. You need to run a 
benchmark at least for a second to get reliable information about 
timing. INstead of 24 times, call your function 20000 times in loop.

	Christian




More information about the Python-list mailing list