On Wednesday, May 14, 2014 5:09:18 PM UTC+2, Nathann Cohen wrote: > > > Or, if your code contains the is_prime_power() logic, just assign the > > appropriate function (cached/non-cached) to some variable f and > subsequently > > call f() instead of a(). > > I don't follow you.... > > Let us say that I have a very complicated function a(), which builds > things, and that at some (late) level in the computation actually knows if > it CAN build it or not. > > I would like to cache true/false answers because it is cheap to save, but > the complete result is too much to save. On the other hand, I don't want to > split the function into two, because it would mean copy/pasting the first > part of the function. > It could return None (let's think about null pointers) or an invalid object of the same type (let's say NaN)? In comparison with raising an error, that could be cached I guess.
I also do not really like that a function returns different kind of things. -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at http://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.