This may not be a Python specific question, but here it goes:
I am trying to solve a numerical problem of the type in which I have to show which elements in a list a = [a_1,a_2,a_3,...] have some property X. However, when I prove it for some a_n, I will sometimes also prove it for other element(s) a_m in the list. So, to speed up the algorithm, I don't want to do the test those elements again.
Now, I can create a list has_property_X and, while iterating over a, test if each element is in the list (and populating that list after testing each element). However, I still have to go through each element in doing this.
Is there a smarter approach?
a_mwas already proved before you reacha_n. So the efficiency gain is only in the case where m > n. There might, however, be some benefit of sorting the list somehow so that elements likely to produce many "bonus proofs" appear at the start of the list.