motivation: sagematrix,it seems, are
not "hashable" and cannot be used as
keys in lists to do groupby/countby

I'd like to make a comment. Matrices in sage are, by default, mutable and hence (just like lists in python) not hashable. You can set a matrix to be immutable, and if its entries are hashable, the matrix itself will also be hashable.