Home > other >  Why Python consumption so big of memory?
Why Python consumption so big of memory?

Time:12-18

Just learning Python, wrote a simple test program, found that Python consumes a lot of memory, no free memory in the process of calculation, excuse me what reason?

 #!/usr/local/bin/env python 

Def is_prime (num) :
If num & lt;
=1: return FalseIf num!=2 and num % 2==0: return False

To=num/2 + 1
For x in range (3, to, 2) :
If num % x==0: return False
Return True

If __name__=="__main__" :
Primes=[]
For x in range (2, 100) :
If is_prime (x) : primes. Append (x)
Print (primes)

The product=primes [0]
For I in range (1, len (primes) :
Print (" prime: "+ STR (primes [I]))
New_prime=product * primes [I] + 1
If is_prime (new_prime) :
Print (" new prime: "+ STR (new_prime))
The else:
Print (STR (new_prime) + "is not the prime! [error] ")
The product *=primes [I]


  • Related