I experience a very strange behaviour. With this code I'll hit a memory limit even for the first integral that is being calculated. If I comment out line 17 and use line 16 instead (so primes = [2,3,5,7] instead of primes = list(primes(2,10))) the computation goes through quickly and without any problems!