Ask Your Question

How does sagemath modify python?

asked 2017-07-13 04:30:32 -0500

screened00 gravatar image

type(3) <type 'sage.rings.integer.Integer'>

So how was sage's python version created, and do I need to learn C to be able to do that ? I would like some easy to begin guide, on how to achienve the same basic things as I'd like to know it's internal workings.

edit retag flag offensive close merge delete


You definitely don't need to learn C!

kcrisman gravatar imagekcrisman ( 2017-07-13 08:29:35 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2017-07-13 06:11:29 -0500

eric_g gravatar image

Sage is indeed preparsing the entries before sending them to Python. To know what Sage is doing exactly with what you are typing, use the command preparse, with your Sage command passed as a string:

sage: preparse("3")
sage: preparse("3+2")
sage: preparse("x^2")
edit flag offensive delete link more


Yes. And beyond the preparsing and adding lots of functions, there are a few other things that are (slightly) redefined like sum which expand their usefulness. For 99% of purposes Sage can be thought of as Python with extra sugar.

kcrisman gravatar imagekcrisman ( 2017-07-13 08:30:36 -0500 )edit
John Palmieri gravatar imageJohn Palmieri ( 2017-07-13 10:31:13 -0500 )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

1 follower


Asked: 2017-07-13 04:30:32 -0500

Seen: 45 times

Last updated: Jul 13