Re: Pari Python



Anton Mellit wrote:
Hi,

I am working on a Pari-Python module (see about GP/PARI at
http://pari.math.u-bordeaux.fr/). Similar project was started by
Stefane Fermigier 12 years ago (you can find a post about it on this
newsgroup). You can see some screenshots on my blog (http://
mellit.wordpress.com/2007/10/28/pari-python/). I reproduce the text on
my blog here.

I finished some working version of the pari-python module. I tried to
make it is close as possible to the standard PARI shell, at the same
time using the standard python syntax. Here I put some screenshots. I
didn’t make a proper package distribution for python (the code still
looks ugly and I still don't know how to make proper distributions),
but if someone is interested to test it send me an email. This is in
early alpha stage. A lot of things are not working. I imported almost
all functions of gp by an automated perl script but I don’t know which
of them actually work and which not.

There are two special difficulties you may notice about python. The
first one is the power operation. In python it is ‘**’, whereas ‘^’ is
reserved for the bitwise xor. I made some little changes to the python
source so that ‘^’ and ‘^=’ now work as power, and ‘^^’ and ‘^^=’ work
as xor if you still want to use it. This is done by modifying about 30
lines of source code in several files: Include/token.h, Modules/
parsermodule.c, Parser/tokenizer.c, Python/ast.c, Grammar/Grammar.

The second difficulty is that expressions like ‘1/2′ produce 0 in
python. For this my module installs my own handler for the operation
‘divide’ for integers and longs. That’s it. In other respects it is a
normal python module.

I will greatly appreciate any feedback.

Have you looked at SAGE at all? They already have wrappers for Pari.

http://www.sagemath.org/

I don't recommend continuing to modify core parts of Python just for your
module. It means that you will break other Python modules. If you can't use
other Python modules with your module, what's the point of using Python at all?

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco

.



Relevant Pages

  • Re: Finding a modules sub modules at runtime
    ... Yields (module_loader, name, ispkg) for all submodules on path, ... that looks nice...but what version of Python is that? ... "I have come to believe that the whole world is an enigma, a harmless enigma ...
    (comp.lang.python)
  • Re: list index()
    ... Python is different than those languages. ... Exceptions are used much more ... "I have come to believe that the whole world is an enigma, a harmless enigma ...
    (comp.lang.python)
  • Re: gmpy and counting None
    ... numerical comparison in Python. ... is the logical choice, the 0 case is NOT a bug, "this behaviour ... That it was by design? ... "I have come to believe that the whole world is an enigma, a harmless enigma ...
    (comp.lang.python)
  • Re: gmpy and counting None
    ... numerical comparison in Python. ... That it was by design? ... maybe the intent needs to be re-thought. ... "I have come to believe that the whole world is an enigma, a harmless enigma ...
    (comp.lang.python)
  • Re: Looking for a Duo - file comparison and a file parser
    ... I'm thinking of writing a file comparison utility in python. ... for this I hope a parser will be required. ... "I have come to believe that the whole world is an enigma, a harmless enigma ...
    (comp.lang.python)