--
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+...@googlegroups.com.
To post to this group, send email to sage-...@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
To view this discussion on the web visit https://groups.google.com/d/msgid/sage-devel/933290b2-697e-4766-9f28-d0486a585107%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
I think this is one disadvantage of using the cached_method decorator, instead of the clumsier way of actually storing the result in the object, eg. by setting X._genus. In your example I cannot think of a reason why we would not want to store the genus as an attribute after computing it.
Hi!
Is it a Python object?
A cached method (if that hasn't changed since I last looked at the code)
stores the cached values in some dict stored as an attribute, and when
you pickle the object (at least when no __reduce__ method interferes),
it should automatically store that attribute.
But you say that the method is called "genus". So, probably it has not
function arguments, right? It could be that the cache is stored
differently in that case.
I think if pickling doesn't preserve the content of the cached method
then it is a bug.
There is the do_pickle argument, e.g. from TFM:sage: class C:....: @cached_method(do_pickle=True)....: def __hash__(self):....: return id(self)
Note that it can cause the following problem: Not every circularly dependent collection of cython objects can be pickled. Cached values can make the difference between what can and cannot be pickled. So whether or not pickling works can't reliably be tested in that case.
From the code, I learned that there is "do_pickle" option. With "do_pickle=True", the content of the cached method is indeed preserved with an experimental class. I will check again with my production code.
I think if pickling doesn't preserve the content of the cached method
then it is a bug.