Open williamstein opened 14 years ago
Currently, elements of residue fields are the same class as elements of any other finite field (IntegerMod_gmp, FiniteFieldElement_givaro, etc). Only the parent records the fact that they're actually in a residue field. We can change the lift method on all such elements to call the parent's lift method, but that's going to impose a performance penalty on every IntegerMod's lift.
I think the right solution is as follows. I want to make a common base class FiniteRingElement that all of the finite field elements and integermods will inherit from (currently their common superclass is CommutativeRingElement). This class can then have a Cache object that will serve the purpose of NativeIntStruct, Cache_givaro and Cache_ntl_gf2e (once FiniteField_ntl_gf2e is converted to Python). Each subclass will have a corresponding subclass of Cache defined.
On the common Cache we can hang things like _is_field and _use_parent_lift. Then elements can have C access to these attributes.
I tried changing the superclasses of IntegerMod and FiniteFieldElement_givaro to a common one, but got some strange error about Givaro not being able to find the sub method. If someone else wants to do it I'd be happy. :-)
Make this work:
CC: @roed314
Component: number fields
Issue created by migration from https://trac.sagemath.org/ticket/8340