Ask Your Question

Why would someone use .sage vs .py?

asked 2012-09-27 00:37:21 +0200

SLOtoSF gravatar image

updated 2012-09-27 09:12:40 +0200

kcrisman gravatar image

Why would someone use .sage vs .py? What's recommended? What are the pros and cons? There are questions people ask like: "This can be done in Sage but I can't do it in my python file?" Why would they do anything in python if they could just do it in Sage?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2012-09-27 10:21:54 +0200

Sage is a (very, very big) python library, and it does not (natively) run on Windowz. "Pure" python is smaller, much more lightweight and easier to install and run.

Just in case, note that .sage and .py are file extensions. In fact, Sage internally "preparses" every .sage file and converts it into .py file. So in particular, if you have a file named f.sage, then do not keep a file named in the same directory, as Sage would overwrite it!

edit flag offensive delete link more


Though I think the poster is wondering about writing things that could use Sage but as .py files, perhaps?

kcrisman gravatar imagekcrisman ( 2012-09-27 13:03:03 +0200 )edit

Yes, I am looking for more of a qualitative analysis. The Developer's Guide gives the example of creating new directories and storing python files. Why would it do so if .sage files work just as well without the added issue of importing modules? Is it possible that the Python files can be reused elsewhere? I know that in different situations there is more than one way to solve a problem, I'm wondering why I would ever do things with .py files.

SLOtoSF gravatar imageSLOtoSF ( 2012-09-27 13:42:59 +0200 )edit

To perhaps help with the response, here is a question which highlights something .sage files can't do, but .py files can:

SLOtoSF gravatar imageSLOtoSF ( 2012-09-27 14:00:14 +0200 )edit

Also Dima, I tried to have a .sage file but sage wasn't registering the .sage file I was building it, even when i modified it. It seems for now I will use the blanket "from sage.all import *" statement at the top of each python file.

SLOtoSF gravatar imageSLOtoSF ( 2012-09-27 14:28:19 +0200 )edit

Again, use `load` or `attach`. Remember, the developer guide is for people intended to develop **new material inside of Sage**, not people developing their own other materials.

kcrisman gravatar imagekcrisman ( 2012-09-27 14:41:21 +0200 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2012-09-27 00:37:21 +0200

Seen: 716 times

Last updated: Sep 27 '12