Skip to content
This repository was archived by the owner on Jan 30, 2023. It is now read-only.

Commit e71808c

Browse files
committed
Trac 21755: export sage.libs.pari.gen.new_ref()
1 parent 26d4124 commit e71808c

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

src/sage/libs/pari/gen.pxd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ cdef class gen_auto:
1111
cdef class gen(gen_auto):
1212
pass
1313

14+
cdef gen new_ref(GEN g, gen parent)
1415
cpdef gen objtogen(s)

src/sage/libs/pari/gen.pyx

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4579,28 +4579,28 @@ cdef class gen(gen_auto):
45794579
deprecation(18203, "rnfpolredabs() is deprecated in PARI, port your code to use rnfpolredbest() instead")
45804580
return gen_auto.rnfpolredabs(*args, **kwds)
45814581

4582+
45824583
cdef gen new_ref(GEN g, gen parent):
45834584
"""
4584-
Create a new gen pointing to the given GEN, which is allocated as a
4585-
part of parent.g.
4585+
Create a new ``gen`` pointing to ``g``, which is allocated as a
4586+
part of ``parent.g``.
45864587
45874588
.. note::
45884589
4589-
As a rule, there should never be more than one sage gen
4590-
pointing to a given Pari GEN. So that means there is only
4591-
one case where this function should be used: when a
4592-
complicated Pari GEN is allocated with a single gen
4593-
pointing to it, and one needs a gen pointing to one of its
4594-
components.
4590+
As a rule, there should never be more than one ``gen``
4591+
pointing to a given PARI ``GEN``. This function should only
4592+
be used when a complicated ``GEN`` is allocated with a single
4593+
``gen`` pointing to it, and one needs a ``gen`` pointing to
4594+
one of its components.
45954595
4596-
For example, doing x = pari("[1,2]") allocates a gen pointing to
4597-
the list [1,2], but x[0] has no gen wrapping it, so new_ref
4598-
should be used there. Then parent would be x in this
4599-
case. See __getitem__ for an example of usage.
4596+
For example, doing ``x = pari("[1, 2]")`` allocates a ``gen``
4597+
pointing to the list ``[1, 2]``. To create a ``gen`` pointing
4598+
to the first element, one can do ``new_ref(gel(x.g, 1), x)``.
4599+
See :meth:`gen.__getitem__` for an example of usage.
46004600
46014601
EXAMPLES::
46024602
4603-
sage: pari("[[1,2],3]")[0][1] ## indirect doctest
4603+
sage: pari("[[1, 2], 3]")[0][1] # indirect doctest
46044604
2
46054605
"""
46064606
cdef gen p = gen.__new__(gen)
@@ -4609,7 +4609,7 @@ cdef gen new_ref(GEN g, gen parent):
46094609
p.refers_to = {-1: parent}
46104610
return p
46114611

4612-
4612+
46134613
cpdef gen objtogen(s):
46144614
"""
46154615
Convert any Sage/Python object to a PARI gen.

0 commit comments

Comments
 (0)