Add fallback implementation in case gmpy is missing