list comparison vs integer comparison, which is more efficient?

Mark Lawrence breamoreboy at yahoo.co.uk
Sun Jan 4 07:30:33 EST 2015


On 04/01/2015 12:22, Christian Gollwitzer wrote:
> 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
>

Maybe using a custom built tool such as 
https://docs.python.org/3/library/timeit.html#module-timeit ?

-- 
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence




More information about the Python-list mailing list