Hi Maarten, On 28 Okt., 15:32, Maarten Derickx <m.derickx.stud...@gmail.com> wrote: > Well, it is supported if you make the attribute a property. Since most of > those things are already functions it would be very easy > > ... > > http://docs.python.org/library/functions.html#property
Thank you, I didn't know "properties" before. But I think it is not the right thing: sage: class Bar(object): ....: @property ....: def property_test(self): ....: print "calling test" ....: return 5 ....: @lazy_attribute ....: def lazy_test(self): ....: print "calling test" ....: return 7 ....: sage: b = Bar() sage: b.property_test calling test 5 sage: b.property_test calling test 5 sage: b.lazy_test calling test 7 sage: b.lazy_test 7 Hence, * A property would be called over and over again and would do the same computation over and over again. * A cached method would be called over and over again, but would do the computation only once. * A lazy attribute would be called only once and thus also do the computation only once. My suggestion comes from the observation that one can save a considerable amount of time by changing super_categories and all_super_categories from cached_method into lazy_attribute. It seems that a change from cached_method into property would have the opposite effect. By the way, I tried to modify the preparser so that "Foo.some_lazy_attribute?" would show the documentation of "Foo.__class__.some_lazy_attribute", but that didn't work well. So, the question remains whether the speed-up makes up for the more difficult access to the documentation: Is it acceptable that the users need to do C.__class__.super_categories? in order to learn what C.super_categories does? Comments on #11943 (or a review:) are welcome! Cheers, Simon -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org