#4836: pari types getattr() function ugly and inefficient
-------------------------+--------------------------------------------------
Reporter: cremona | Owner: tbd
Type: enhancement | Status: new
Priority: major | Milestone:
Component: algebra | Keywords:
-------------------------+--------------------------------------------------
the pari interface relies on the function getattr(), e.g. as in
{{{
zk_basis = K.pari_nf().getattr('zk')
}}}
but I *really* don't like this function! Each of these dot-attributes
in pari is a short-cut, in this case to {{{K.pari_nf()[6]}}}, as these are
easier when running gp than remembering which field is which in the
nf/bnf structures. There are not very many of these (I started making
a list). But what I do not like is the implementation of getattr() in
Sage:
{{{
def getattr(self, attr):
t0GEN(str(self) + '.' + str(attr))
_sig_on
return self.new_gen(t0)
}}}
So it converts the nf into a string (in my examples, that's a string
of length 59604), adds ".zk" to it, and reparses the input (using the
gp parser).
We could instead implement the getattr function with a dictionary like
this for an nf:
{{{
{('pol',1), ('sign',2), ('r1',(2,1)), ('r2',(2,2)),
}}}
etc (where the numbers are indices into the array so should actually
have 1 subtracted
from them).
The only disadvantage I can see for this is that new versions of pari
might change the indices -- though I doubt that happens often, as you
can see from the existence of unused fields which are just there to
pad arrays to the expected length. And in any case doctests would
find these.
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/4836>
Sage <http://sagemath.org/>
Sage - Open Source Mathematical Software: Building the Car Instead of
Reinventing the Wheel
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en
-~----------~----~----~----~------~----~------~--~---