File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed
Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -167,6 +167,15 @@ cdef _py_gcd(ullong a, ullong b):
167167 return a
168168
169169
170+ cdef ullong _c_gcd(ullong a, ullong b):
171+ if a <= < ullong> INT_MAX and b <= < ullong> INT_MAX:
172+ return _igcd[uint](< uint> a, < uint> b)
173+ elif a <= < ullong> LONG_MAX and b <= < ullong> LONG_MAX:
174+ return _igcd[ulong](< ulong> a, < ulong> b)
175+ else :
176+ return _igcd[ullong](a, b)
177+
178+
170179cdef _gcd_fallback(a, b):
171180 """ Fallback GCD implementation if _PyLong_GCD() is not available.
172181 """
@@ -1660,7 +1669,7 @@ cdef tuple _parse_fraction(AnyString s, Py_ssize_t s_len):
16601669 # Special case for 'small' numbers: normalise directly in C space.
16611670 if inum and decimal_len:
16621671 idenom = 10 ** < ullong> decimal_len
1663- igcd = _igcd[ullong] (inum, idenom)
1672+ igcd = _c_gcd (inum, idenom)
16641673 if igcd > 1 :
16651674 inum //= igcd
16661675 denom = idenom // igcd
You can’t perform that action at this time.
0 commit comments