Ask Your Question
1

Using from Python (breaking the monolith)

asked 2015-02-28 10:34:49 +0100

Stefan Witzel gravatar image

Sage contains a many libraries (or Cython wrappers to libraries) that would be useful in other Python programs (to me anyway). So I would like to use some of them isolated from within Python programs. I understand that this is not easily possible. Is it still possible at all? This is actually not so much about how to use Sage from Python but about carving pieces out of the monolithic structure of Sage. (At the moment it seems like I have to implement all kinds of stuff from scratch which seems silly since much of it is already there.)

Concretely: Among other things I want to compute with matrices that have entries in rings of Laurent series over finite fields.

Now you will say: just write a Sage script rather than a Python script. So here are my reasons to prefer Python with isolated libraries (in increasing order of importance):

  1. Practical: putting the full 1.5 GB (?) of sage in home on my office computer pushes me beyond the quota limit.
  2. Extendability: Not everything I need is available in Sage. But if I want to extend the code I will have do wade through the Sage code making changes here and there and then defend them against updates (and maybe adjust the build process). This seems like a lot of hassle.
  3. Verifiability: At some point my code will (hopefully) produce some solutions to some problem and I will want to say (maybe in a published paper) "these are solutions and they are all solutions to the problem". Then critical minds will not believe me and all I can say is: "Well, you only have to check the correctness of my 200 lines of code (say). -- Plus of course everything in the Sage git repository, plus the libraries it depends on (at least the part that my code uses, which you will have to work out for yourself); and make sure to patch in these changes I made here and there!"
edit retag flag offensive close merge delete

Comments

I fully agree with you, and I am certainly not the only one. Unfortunately, Sage is a monolith, and there is little you can do right now. Making Sage more modular is one of the goals of this submitted EU project https://github.com/sagemath/grant-europe, that will hopefully begin next september.

Luca gravatar imageLuca ( 2015-02-28 16:33:00 +0100 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2015-03-01 00:37:26 +0100

vdelecroix gravatar image

Hello,

Right. This is a problem of Sage. But it would be a tremendous amount of work to isolate a part of Sage (not talking about the fact that you would also need to maintain it). Some people (including me) are in favour of something more modular. But the focus is currently not on having some part of Sage isolated but having Sage isolated from its components (i.e. third party softwares and libraries such as GAP, Pari/GP, mpir, etc).

And some comments about your reasons

  1. You are definitely right! If you are using (Gentoo)[https://www.gentoo.org/] it is already possible to use Sage over your system. Which means that you only have to install a lot of standard packages (singular, GAP, etc) + the Sage library. A lot of effort is currently done to have the same in (Debian)[https://www.debian.org/] but it is not yet ready. If Sage is finally usable directly on your system this would reduce dramatically the size (it is only ~63M of source code). You are very welcome to help. Sage is an open source project which means that it is mainly developed by its users.

  2. It is very simple to have your own Python/Cython files outside of Sage as an independent Sage code. A priori there is no need to dig into Sage source code. But it of course depends on your needs. You might also want to contribute to Sage source code. It is how Sage gets better.

  3. If you really want something proven you should neither use Sage nor Python (except if you can get a certificate of your computation). If you just want a strong belief that the result is the one you have, you can just do as everyone is doing within Sage: write careful doctests for each piece of code which go through all possible branch of the algorithm. And possibly add some randomized testing.

edit flag offensive delete link more

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: 2015-02-28 10:34:49 +0100

Seen: 354 times

Last updated: Mar 01 '15