Given a large N, I need to iterate through all phi(k) such that 1 < k < N :
O(N logN)
Is this from Project Euler 245? I remember that question, and I have given up on it.
The fastest way I found for calculating totient was to multiply the prime factors (p-1) together, given that k has no repeated factors (which was never the case if I remember the problem correctly).
So for calculating factors, it would probably be best to use gmpy.next_prime or pyecm (elliptic curve factorization).
You could also sieve the prime factors as Jaime suggests. For numbers up to 1012, the maximum prime factor is below 1 million which should be reasonable.
If you memoize factorizations, it could speed up your phi function even more.