This is exactly the kind if thing we try to avoid. I'd like to see the files (if they're disclosable of course), or perhaps you could come up with a whittled-down example.
On Tue, Aug 2, 2011 at 7:22 PM, VictorMiller <victorsmil...@gmail.com> wrote: > Robert, The .py and .pyx files are identical. I copied one to the > other, and just in case I checked with diff. It's very puzzling. > > Victor > > On Aug 2, 8:19 pm, Robert Bradshaw <rober...@math.washington.edu> > wrote: >> On Tue, Aug 2, 2011 at 11:29 AM, William Stein <wst...@gmail.com> wrote: >> > 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, >> >> yet... >> >> > 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? >> >> You could also write your own with_logging that doesn't try to access >> __name__ or __doc__ and decorate with that. >> >> I'm very curious what goes awry. Did you make any changes other than >> changing the file from .py to .pyx and compiling it? >> >> - Robert > > -- > 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 > -- 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