python for lispers, gently

70 views
Skip to first unread message

Dima Pasechnik

unread,
Mar 22, 2015, 6:33:05 PM3/22/15
to sage-...@googlegroups.com, sage-devel
There is a great way to contribute to core Sage, which is written in a language not everyone is apparently keen on...

Namely, one can do it in Lisp:
http://docs.hylang.org/en/latest/#
(more precisely, in a Lisp dialect running on top of Python)



William Stein

unread,
Mar 22, 2015, 6:41:11 PM3/22/15
to sage-flame
People could also just contribute lisp code, which would run via ECL
(=embedded common lisp), which is included in Sage. Or they could
improve Maxima, which indirectly contributes to Sage...

I wonder how Hy and ECL performance compares...

William

>
>
> --
> You received this message because you are subscribed to the Google Groups
> "sage-flame" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sage-flame+...@googlegroups.com.
> To post to this group, send email to sage-...@googlegroups.com.
> Visit this group at http://groups.google.com/group/sage-flame.
> For more options, visit https://groups.google.com/d/optout.



--
William (http://wstein.org)

rjf

unread,
Mar 23, 2015, 1:00:15 AM3/23/15
to sage-...@googlegroups.com


On Sunday, March 22, 2015 at 3:41:11 PM UTC-7, William Stein wrote:
On Sun, Mar 22, 2015 at 3:33 PM, Dima Pasechnik <dim...@gmail.com> wrote:
> There is a great way to contribute to core Sage, which is written in a
> language not everyone is apparently keen on...
>
> Namely, one can do it in Lisp:
> http://docs.hylang.org/en/latest/#
> (more precisely, in a Lisp dialect running on top of Python)
>

People could also just contribute lisp code, which would run via ECL
(=embedded common lisp), which is included in Sage.  Or they could
improve Maxima, which indirectly contributes to Sage...

I'm not sure it is right to respond seriously to a post in Sage Flame,  but
it is certainly true that writing in Lisp for Sage (at least the Maxima component)
is plausible.

There have been for years python-implemented-in-lisp programs (written in lisp).  It would
not surprise me if these were as fast or faster than some python implementations,
since rephrasing python programs as lisp programs makes it possible to run
it through a compiler that (at least for some lisp compilers)  is optimized assembler.

I'm not familiar with ECL's implementation -- maybe it produces C rather than assembler?

 
I wonder how Hy and ECL performance compares...
Well, if python is X times slower than compiled lisp, I suppose Hy would be at
least X times slower also.

Incidentally, my experience with libraries callable from python is that the same
libraries can be called from Lisp.  I looked around for an MPFR library and came
across a python version. I hooked it up to a Lisp. I found that the library was inadequate
with respect to managing memory  (it was difficult or impossible to do the right thing
from the python side), so I ended up loading up some "more native" version... an
MPFR.dll file of some sort.

Anyway using python as an implementation language for another language seems to
me to be plausible only if it is a relatively thin layer and run-time efficiency is
unimportant.  I suppose that goes for using python for doing anything else, also.
(this being sage-flame)

RJF
 

William

>
>
> --
> You received this message because you are subscribed to the Google Groups
> "sage-flame" group.
> To unsubscribe from this group and stop receiving emails from it, send an

Dima Pasechnik

unread,
Mar 23, 2015, 5:29:25 AM3/23/15
to sage-...@googlegroups.com, sage-...@googlegroups.com


On Monday, 23 March 2015 09:06:28 UTC, John Cremona wrote:
I thought that 1 April was traditionally the day we propose rewriting
all of Sage in lisp?

This time I'd like to propose to rewrite Sage in coq.
Certainly, just the fact that it would provide proofs of correctness of
all algorithms implemented, can justify the undertaking...

Dima

 
John

On 22 March 2015 at 23:00, Volker Braun <vbrau...@gmail.com> wrote:
> Of course we include ECL so thats yet another way to run Lisp ;-)
> --
> You received this message because you are subscribed to the Google Groups
> "sage-devel" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> To post to this group, send email to sage-...@googlegroups.com.

Dima Pasechnik

unread,
Mar 23, 2015, 8:31:47 AM3/23/15
to sage-...@googlegroups.com, sage-...@googlegroups.com


On Monday, 23 March 2015 09:06:28 UTC, John Cremona wrote:
I thought that 1 April was traditionally the day we propose rewriting
all of Sage in lisp?

But it just works. I'm not kidding:

(sage-sh) $ hy
hy 0.10.1 using CPython(default) 2.7.8 on Linux
=> (import [sage.all [*]])
=> (var 'x)
x
=> (NumberField (- (* x x) (Integer 2)) 'a)
Number Field in a with defining polynomial x^2 - 2
=>
 



John

On 22 March 2015 at 23:00, Volker Braun <vbrau...@gmail.com> wrote:
> Of course we include ECL so thats yet another way to run Lisp ;-)
>
>
> On Sunday, March 22, 2015 at 11:33:08 PM UTC+1, Dima Pasechnik wrote:
>>

rjf

unread,
Mar 23, 2015, 10:20:36 AM3/23/15
to sage-...@googlegroups.com, sage-...@googlegroups.com
Here's an item that is related but far more edifying.


I looked at the Hy documentation, and it appears that
Hy hardly implements lisp.  It alters the surface syntax
of python to parenthesized prefix, and tosses in a very small subset of lisp.

Hy resembles a 3-week project in a computer science compiler class.

There is rarely a good reason to REWRITE parts of Sage in some  language X.

That is why I am concerned when someone proposes to REWRITE parts of Sage
in Python.  

Rewriting pieces that exist in C, C++, Lisp... strikes me as makework projects
that likely result in slow partial broken versions of working code.


Reply all
Reply to author
Forward
0 new messages