Reputation: 1549
I have an iterative function, phi, that calls itself many times to return the correct result.
def phi(n, primes, phis):
where primes is a list of primes, 1 < n < 10,000,000 and phis is a list of totient values over the same range of n.
Is it expensive computation-wise to do this in Python? My guess is it does not cost much as we are dealing with pointers in Python so all that will get passed is the pointer? However with this function even the POINTERS would get passed a lot (read: sh##load). Is that computationally expensive?
Upvotes: 4
Views: 324
Reputation: 143092
You are right, you are not passing the whole list but a pointer. You'll be incurring the regular overhead for function calls which will be much more than the passing of a pointer/parameter.
Upvotes: 5