4 ms·
The python benchmark is contaminated. Lots of <= checks, increasing variables, etc. Those things need to be left out of the timing. How about using itertools.pr
by algorias 17y ago
The python benchmark is contaminated. Lots of <= checks, increasing variables, etc. Those things need to be left out of the timing. How about using itertools.product instead?
for latA, lngA, latB, lngB in itertools.product(*[xrange(-90,91), xrange(-180,181)]*2):
distance(latA, lngA, latB, lngB)
Not sure it's faster, but certainly more idiomatic.
Also, the 2nd python example doesn't work; you need to drop all the 'math.' and use radians, sqrt, etc directly.