Hacker News new | ask | show | jobs
by zarzavat 1172 days ago
I don’t know if numpy fixed this, but it used to be that mixing Python numbers with numpy in a tight loop is horribly slow. Try hoisting max_dist out of the loop and replacing it with max_dist_np that converts it to a numpy float once.
1 comments

Speaking of this, I once find that

    for x in numpy.array: 
is 9X slower than

    for x in numpy.array.tolist():
in 2021.