diff --git a/src/sage/misc/lazy_import.pyx b/src/sage/misc/lazy_import.pyx index 58365b2b272..9bac24a371e 100644 --- a/src/sage/misc/lazy_import.pyx +++ b/src/sage/misc/lazy_import.pyx @@ -36,6 +36,23 @@ that (s)he can remove the flag:: UserWarning: Option ``at_startup=True`` for lazy import ZZ not needed anymore Integer Ring +.. WARNING:: + + After the first usage, the imported object is directly injected into the + namespace; however, before that, the :class:`LazyImport` object + is not exactly equivalent to the actual imported object. For example:: + + sage: from sage.misc.lazy_import import LazyImport + sage: my_qqbar = LazyImport('sage.rings.qqbar', 'QQbar') + sage: my_qqbar(5) == QQbar(5) # good + True + sage: isinstance(QQbar, Parent) + True + sage: isinstance(my_qqbar, Parent) # fails! + False + + To avoid this issue, you may execute the import inside the function instead. + .. SEEALSO:: :func:`lazy_import`, :class:`LazyImport` AUTHOR: diff --git a/src/sage/schemes/curves/projective_curve.py b/src/sage/schemes/curves/projective_curve.py index 09fb3ffd3db..f65da51e1e7 100644 --- a/src/sage/schemes/curves/projective_curve.py +++ b/src/sage/schemes/curves/projective_curve.py @@ -159,7 +159,6 @@ lazy_import('sage.interfaces.singular', 'singular') lazy_import('sage.rings.number_field.number_field', 'NumberField') -lazy_import('sage.rings.qqbar', ['number_field_elements_from_algebraics', 'QQbar']) from .curve import Curve_generic @@ -1450,9 +1449,10 @@ def ordinary_model(self): + (1/16*a + 1/16)*x*y*z^2 + (3/16*a + 3/16)*y^2*z^2 + (-3/16*a - 1/4)*y*z^3 + (1/16*a + 3/32)*z^4) """ - # helper function for extending the base field + from sage.rings.qqbar import number_field_elements_from_algebraics, QQbar def extension(self): + # helper function for extending the base field F = self.base_ring() pts = self.change_ring(F.embeddings(QQbar)[0]).rational_points() L = [t for pt in pts for t in pt]