I think there's a simple way to represent quaternions as 3x3 matrices. So you could probably just store them that way and use NumPy for the arithmetic.