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 [email protected]
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
-~----------~----~----~----~------~----~------~--~---