Hi!
> What I suggest would apply to all interfaces and to all classes
> deriving from Parent that use the generic implementation for that
> interface.
My suggestion is now a patch, namely for ticket #2420. It not only
provides the interface cache framework for Parents, but provides a GAP
representation of polynomial rings.
The cache framework is backwards compatible. In particular, sage -
testall passes. Here is a brief account what I suggest to do if you
want to use the interface cache for your favourite Parent structure
and your favourite interface (say, GAP, but it should work perfectly
alike for magma, PARI etc.):
* Do *not* provide a _gap_ method; otherwise you are supposed to take
care of caching, yourself.
* If your parent structure has no _gap_ method but has a _gap_init_
method then you are fine: The interface representation will now be
cached.
* Your _gap_init_ may accept an (optional) argument that tells which
interface instance should be used.
The third point is useful for recursive constructions: Assume you have
a polynomial ring P and have an instance MyGap of GAP (different from
sage.all.gap). For constructing MyGap(P), it makes sense to construct
MyGap(P.base_ring()) first. Since MyGap(P.base_ring()) is cached,
MyGap(P.base_ring()).name() is a short but unique string that can be
used in the string representation returned by P._gap_init_(MyGap).
#2420 is ready for review (hint...).
Unfortunately, in order to make the interface work for polynomial
rings over cyclotomic fields and number fields (the original topic of
the ticket), I had to work on top of five other tickets, namely #9205,
#9438, #9423, #8909 and #5618. Sorry for that, but some of them have a
positive review anyway.
Cheers,
Simon