fractions reimplementation in Cython