sagemath / sage

Main repository of SageMath
https://www.sagemath.org
Other
1.46k stars 482 forks source link

algebraic_closure of finite field cannot be copied #38988

Open user202729 opened 4 days ago

user202729 commented 4 days ago

Steps To Reproduce

sage: deepcopy(GF(5).algebraic_closure())
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
...
TypeError: sage.misc.fast_methods.WithEqualityById.__new__(AlgebraicClosureFiniteField_pseudo_conway_with_category) is not safe, use AlgebraicClosureFiniteField_pseudo_conway_with_category.__new__()

Expected Behavior

should just work

Actual Behavior

error

Additional Information

No response

Environment

Checklist

user202729 commented 4 days ago
        This non-uniqueness problem can in principle be solved by
        using *Conway polynomials*; see for example
        :wikipedia:`Conway_polynomial_(finite_fields)`. These have
        the drawback that computing them takes a long time.  Therefore
        Sage implements a variant called *pseudo-Conway polynomials*,
        which are easier to compute but do not determine an algebraic
        closure up to unique isomorphism.

        The output of this method is cached, so that within the same
        Sage session, calling it multiple times will return the same
        algebraic closure (i.e. the same Sage object).  Despite this,
        the non-uniqueness of the current implementation means that
        coercion and pickling cannot work as one might expect.  See
        below for an example.

Maybe that's why? Still, is it desirable to disallow copying?


Okay maybe that's not why, but there's this

sage: from sage.rings.algebraic_closure_finite_field import AlgebraicClosureFiniteField_pseudo_conway
sage: AlgebraicClosureFiniteField_pseudo_conway.__new__(AlgebraicClosureFiniteField_pseudo_conway)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[3], line 1
----> 1 AlgebraicClosureFiniteField_pseudo_conway.__new__(AlgebraicClosureFiniteField_pseudo_conway)
TypeError: sage.misc.fast_methods.WithEqualityById.__new__(AlgebraicClosureFiniteField_pseudo_conway) is not safe, use AlgebraicClosureFiniteField_pseudo_conway.__new__()

On the other hand, strangely enough, pickling and unpickling the field works perfectly fine?