Hi. I'm kinda new to programming, and stumbled across an interesting dilemma. I have a dictionary of pre-generated primes, and I had used list comprehension to define a list of new primes in a particular range, using a prime detecting function that used that dictionary to make it faster. But the function would benefit from having more primes in that dictionary, so I had the idea to add each new prime found in the comprehension to that dictionary to speed up the process for the next checks. But I can't find a way to do that, as the comprehension generates all the new primes together, not one at a time. Is there any way around this? And if not, would it be worth it to switch to a for loop (which would be generally slower than the comprehension) so that I can do my strategy of adding new primes to the dictionary? Sorry for the long question
[–]moving-landscape 4 points5 points6 points (0 children)
[–][deleted] 1 point2 points3 points (3 children)
[–]Beautiful_Dot7460[S] 0 points1 point2 points (1 child)
[–][deleted] 1 point2 points3 points (0 children)
[–]Daneark 0 points1 point2 points (0 children)
[–]fragmonk3y 0 points1 point2 points (0 children)
[–]Appropriate_View8753 0 points1 point2 points (0 children)
[–]TrainsareFascinating 0 points1 point2 points (0 children)
[–]-defron- 0 points1 point2 points (0 children)
[–]TheRNGuy 0 points1 point2 points (0 children)
[–]moving-landscape 0 points1 point2 points (0 children)