SymPy also has an integer_nthroot function that quickly finds the integer n-th root of a number and tells you whether it was also that:
>>> integer_nthroot(primorial(12)+1,3) (19505, False)
So your function could be
def is_perfect_cube(x): return integer_nthroot(x, 3)[1]
(And since SymPy is open source, you can look at the procedure to see how integer_nthroot works.)
smichr
source share