More bits from your code: neighbours = list() ==> neighbours = []
If you have a recent enough version of Python you can use: candidate_is_neighbour = any(distance < n[1] for n in neighbours) Instead of: candidate_is_neighbour = bool([1 for n in neighbours if distance < n[1]]) It's shorter & simpler, and it stops as soon as it finds a true condition. Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list