I'm interested in whether there is a way to further improve a fast version of a function used in a homework assignment I received recently (I've already submitted the completed work).from math import logdef func_fast(mass, density):    return sum(map((log(mass * density)).__truediv__, range(1,10001)))def func_slow(mass, density):     total = 0.0     for i in range(10000):         masslog = log(mass * density)         total += masslog/(i+1)    return totalmass = 2.5 density = 12.0The fast version times in around 2-2.5ish seconds while the slow version nets 6-7 seconds.
Faster way to perform function calculation in Python?
python;performance;python 3.x