Thanks for the information! Using "Integer=int" has fixed most of my problems. Turning off the preparser prevents "load cfuncs.spyx" from working, so I haven't been using that.
The main problem in my code, I discovered, was the use of Python lists and numpy arrays. By accessing the contents of the numpy arrays directly in Cython, I found that my code ran about 1,000 times faster. I remember hearing that there might soon be new Cython features that would allow fast access to numpy arrays. Is that work still in progress? Best wishes, Stephen On Fri, Apr 25, 2008 at 9:03 AM, William Stein <[EMAIL PROTECTED]> wrote: > > On Fri, Apr 25, 2008 at 6:56 AM, Stephen Hartke <[EMAIL PROTECTED]> wrote: > > I currently have some Sage code in a file called main.sage. I call this > from > > the Sage command line interpreter with "load main.sage". After > profiling my > > code, I moved a few functions into a "cfuncs.spyx" which I call with a > "load > > cfuncs.spyx" command in main.sage. This works great, and cfuncs.spyx is > > automatically compiled when I load main.sage. > > > > However, I have been having difficulty with the casting between Python > ints, > > numpy int32s, and Sage integers. Besides type casting problems, this > also > > seems to significantly reduce the speed of my code. Is there a way to > > prevent Sage from wrapping constants with "Integer()"? > > You can write > > Integer = int > n = 5 > > somewhere, and then the wrapping has no effect. > You could also just explicitly put > n = int(5) > and then the wrapping is undone. > Finally, you can put an r after any integer literal to make it "raw", > and then it won't be preparsed at all: > n = 5r > Another option is just to give the command > preparser(False) > to completely turn off the preparser. > > All the same above comments apply for floating point literals as well. > > > > > Alternatively, is > > there a way to call a Cython .pyx file from within a Python .py file > (all > > running inside Sage, of course)? > > > > > > --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---