I don't know what np.prod and sp.uint64 do, but I can tell you about the p - 1 algorithm, which was invented by John Pollard in 1974.
Pollard's algorithm is based on Fermat's Little Theorem a ^ p == a (mod p), which when a != 0 can be stated a ^ (p - 1) == 1 (mod p) by dividing a through the expression. As a consequence, if p - 1 divides m, then p divides gcd(2^m - 1, n). Pollard's p - 1 algorithm computes m as the least common multiple of the integers less than a bound b, so that if all the factors of p - 1 are less than b, then gcd(2 ^ lcm(1..b) - 1, n) is a factor of n. The least common multiple is computed by multiplying primes less than b by their multiplicities less than b:
function pminus1(n, b)
c := 2
for p in primes(b)
pp := p
while pp < b
c := powerMod(c, p, n)
pp := pp * p
g := gcd(c-1, n)
if 1 < g < n return g
error "factorization failed"
An optional second stage searches for a "large prime" between b1 and b2 that combines with the least common multiple of the first stage to find a factor. The second stage requires only a modular multiplication for each prime rather than a modular exponentiation, making it quite fast, and the second-stage gcds can be computed in batches. The cache is small but important to the efficiency of the function.
function pminus1(n, b1, b2)
c := 2
for p in primes(b1)
pp := p
while pp < b
c := powerMod(c, p, n)
pp := pp * p
g := gcd(c-1, n)
if 1 < g < n return g
k := 0
for q in primes(b1, b2)
d := q - p
if d is not in cache
x := powerMod(c, d, n)
store d, x in cache
c := (c * x(d)) % n
p := q
k := k + 1
if k % 100 == 0
g := gcd(c-1, n)
if 1 < g < n return g
g := gcd(c-1, n)
if 1 < g < n return g
error "factorization failed"
It is possible that Pollard's p - 1 method may fail to find a factor of n; it depends on the factorization of n - 1 and the bounds you have chosen. The way to check is to factor n - 1 yourself, then call Pollard's method with a b that is larger than the largest factor of n - 1. For instance, if you want to factor n = 87463 = 149 * 587, note that n - 1 = 87462 = 2 * 3 * 3 * 43 * 113, so call the one-stage algorithm with b = 120 or the two-stage algorithm with b1 = 50 and b2 = 120 and see if you find a factor.
I discuss Pollard's p - 1 factorization algorithm, along with several other factorization algorithms, at my blog. I also give there implementations of the powerMod and gcd functions, in case you are having trouble with your implementations of those functions. And I wrote a simple implementation of the single-stage algorithm, in Python, at http://ideone.com/wdyjxK.