- Is there a methodology used in Python programming to decide safe test values? Something to make sure that accidental large values do not lead to risks.
- I have read that Python discourages type checking. Should type-checking or bound-checking be done in such cases or are there alternatives?
I was working with this code and testing the running times. I accidentally entered a really large number and ran the code. I was able to stop it via task manager when it had reached 850MB RAM usage and going up. I don't want something like that to happen again.
def primes_list(num):
ans = [2]
for i in range(3, num, 2):
temp = False
for j in ans:
if i % j == 0 or j*j > i:
temp = True
break
if temp == False:
ans.append(i)
else:
return ans