On Wed, Feb 28, 2018 at 6:46 PM, Matt Arcidy <marc...@gmail.com> wrote: > I have been struggling to justify the need based on what I have read. I > hope this isn't a dupe, I only saw caching mentioned in passing. > > Also please excuse some of the naive generalizations below for illustrative > purposes. > > Is there a reason memoization doesn't work? If f is truly expensive, using > this syntax only makes sense if you have few comprehensions (as opposed to > many iterations) and few other calls to f. Calling f in 10 comprehensions > would (naively) benefit from memoization more than this. It appears to me > to be ad-hoc memoization with limited scope. is this a fair statement?
Memoization is only an option if the expression in question is (a) a single cacheable function call, and (b) used twice without any variation. If it's any sort of more complicated expression, that concept doesn't work. ChrisA _______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/