Pythonic creation of distance matrix