On Mon, Feb 28, 2011 at 2:35 PM, Simon King <simon.k...@uni-jena.de> wrote: > Hi Robert! > > On 28 Feb., 21:00, Robert Bradshaw <rober...@math.washington.edu> > wrote: >> ... >> Sorry, I forgot to mention that it must be declared as "cdef public >> object __doc__". Otherwise it doesn't create a Python-visible wrapper, >> so you're still (from Python) accessing the class-level __doc__. > > So, is there a difference between "cpdef" and "cdef public"? I wasn't > aware of that.
Currently, cpdef is only for methods (not attributes), though there is talk of changing that. It's probably a bug that we let it through silently. > But that's great, and naturally suggests a patch for coerce_binary. Yep, should be a rather easy one. Is there a ticket yet? > While we are at it: Are similar solutions available for the > cached_method decorators? > > Currently, it fails as follows: > sage: cython('''from sage.all import cached_method > cdef class C: > @cached_method > def f(self,x): > return x > ''') > Traceback (most recent call last): > ... > AttributeError: 'method_descriptor' object has no attribute > 'func_defaults' > > Namely, cached_method tries to obtain certain attributes common to > python functions from its argument. func_defaults is just one among > others. We don't have as much freedom here, as C-defined and python-defined functions are quite different (standard library) objects. In this case, cached_method should recognize method_descriptors/builtin_function_or_method types and handle them differently (if possible). - Robert -- 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