Ask Your Question
0

How does sagemath modify python?

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

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

Comments

You definitely don't need to learn C!

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

1 answer

Sort by ยป oldest newest most voted
2

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

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")
'Integer(3)'
sage: preparse("3+2")
'Integer(3)+Integer(2)'
sage: preparse("x^2")
'x**Integer(2)'
edit flag offensive delete link more

Comments

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 -0600 )edit
1
John Palmieri gravatar imageJohn Palmieri ( 2017-07-13 10:31:13 -0600 )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

Stats

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

Seen: 52 times

Last updated: Jul 13