Ask Your Question
0

How does sagemath modify python?

asked 2017-07-13 11:30:32 +0200

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 15:29:35 +0200 )edit

1 Answer

Sort by ยป oldest newest most voted
2

answered 2017-07-13 13:11:29 +0200

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 15:30:36 +0200 )edit
1
John Palmieri gravatar imageJohn Palmieri ( 2017-07-13 17:31:13 +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

1 follower

Stats

Asked: 2017-07-13 11:30:32 +0200

Seen: 280 times

Last updated: Jul 13 '17