It sucks that Python doesn't have a Matrix class or intelligent multiplication operations for such a class. You can certainly build a Matrix as a list of lists and it'll even perform tolerably for rudimentary stuff. But without multiplication there isn't too much you can do with it. So, Multiplication: def multiply(A, B): # If we are not sure we are getting properly sized input . . . assert(len(B) == len(A[0])) assert([len(A[0]) == len(a) for a in A] == [True] * len(A)) assert([len(B[0]) == len(b) for b in B] == [True] * len(B)) # The magic return [[sum([A[n][m]*B[m][p] for m in range(len(B))]) \ for p in range(len(B[0]))] \ for n in range(len(A))] So the (yeah, I'm slow, shut up) realization: pretty much anything you can express in standard math notation you can do a pretty kickass job of with list comprehensions. Unfortunately, I don't think you can express the above with enumerates instead of range's, so this isn't gonna be O(n x m x p), but rather something worse. Such is the usefulness of the Array package I suppose. Once in a while list-vs-vector is irksome.