Using polynomial rings in cython

asked 2023-09-29 12:11:51 +0200

naf gravatar image


I have a sage script that is mostly made up of python code, but uses the sage implementation of polynomial rings in one variable. I have been trying to convert the script to cython to speed it up, but am getting an error because of the polynomial ring.

The first line of the script is:

t = ZZ['t'].0

which I am using to create the polynomial ring in the variable 't'. When I change the .sage extension to .spyx and try to load the file I get the error:

Syntax error in simple statement list

which points to the second "]" in the line of code.

Is there a simple way to fix this?

edit retag flag offensive close merge delete


What do you mean by "load" the file? If I call the file x.spyx and do %load x.spyx in a Sage session, it works fine.

John Palmieri gravatar imageJohn Palmieri ( 2023-09-30 00:33:07 +0200 )edit

If you mean that sage x.spyx fails, then look at what happens when you did sage x.sage: it created a file called Try renaming that file as x.spyx. Does it work better?

John Palmieri gravatar imageJohn Palmieri ( 2023-09-30 00:35:11 +0200 )edit

This syntax is for babies' convenience. Use t = polygen(QQ, "t") instead.

FrédéricC gravatar imageFrédéricC ( 2023-09-30 07:52:14 +0200 )edit

Thank you, that does the job.

naf gravatar imagenaf ( 2023-10-08 13:05:47 +0200 )edit