On Tue, Aug 2, 2011 at 11:09 AM, VictorMiller <victorsmil...@gmail.com> wrote: > I've written a bunch of functions (some organized in classes) to do > some large computations in a particular finite field (always GF(2^n) > for some odd n). This seems to work fine. I'd like the computation > to be as fast as possible, so the first thing I did was to copy > the .py file to a .pyx file. The good news is that the compiled > cython is at least 30% faster (sometimes more) than the > interpreted .py version. The bad news is that it gives different > results! In trying to track down where things go awry, I made the > following declaration in each > > from sage.misc.decorators import sage_wrap > from string import join > def logged(func): > @sage_wrap(func) > def with_logging(*args, **kwds): > print func.__name__ + '(' + join([str(_) for _ in args],',') > + ')' > return func(*args,**kwds) > return with_logging > > > I then put > @logged > > in from of the defs of a bunch of functions. > > This works as expected with .py version, but when I try to compile > the .pyx version I get the message: > > .... in update_wrapper > setattr(wrapper, attr, getattr(wrapped, attr)) > AttributeError: attribute '__doc__' of 'builtin_function_or_method' > objects not writable > > I think that I understand what's going on here, but are there any
You often can't use decorators with Cython code, since it is compiled (not dynamic). > suggestions as to how to get to the bottom of the differences between > the cython compiled version and the interpreted version? Put in print statements? -- William > > -- > To post to this group, send email to sage-support@googlegroups.com > To unsubscribe from this group, send email to > sage-support+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/sage-support > URL: http://www.sagemath.org > -- William Stein Professor of Mathematics University of Washington http://wstein.org -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org