perf opt: use static_vector types when we know the max arity

fallback to std::vector when the arity is potentially unbounded
have cython code wrap the new C++ templated state

we work around a limitation in cython's templating system
by putting a max cap on relation arity to 4