list comparison vs integer comparison, which is more efficient?

Jonas Wielicki jonas at wielicki.name
Sun Jan 4 07:24:26 EST 2015


On 04.01.2015 13:17, austin aigbe wrote
> Hi Terry,
> 
> No difference between the int and list comparison in terms of the number of calls(24) and time (0.004s). Main part is the repeated call to sqrt().
> 
> 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.

How often did you run your measurement? 4ms is not a whole lot and can
easily be skewed by sudden system load or other noise. You should call
the function more often and/or repeat the measurement several times
before coming to a judgement (except, possibly, that it doesn’t matter).

cheers,
jwi



More information about the Python-list mailing list