File tree Expand file tree Collapse file tree 1 file changed +15
-11
lines changed Expand file tree Collapse file tree 1 file changed +15
-11
lines changed Original file line number Diff line number Diff line change @@ -45,21 +45,25 @@ cdef Obj make_gap_list(sage_list) except NULL:
45
45
- ``a`` -- list of :class:`GapElement`
46
46
47
47
OUTPUT: list of the elements in ``a`` as a Gap ``Obj``
48
+
49
+ TESTS::
50
+
51
+ sage: from sage.doctest.util import ensure_interruptible_after
52
+ sage: for i in range(10):
53
+ ....: with ensure_interruptible_after(0.1):
54
+ ....: ignore = libgap([1000]*10000)
55
+ ....: with ensure_interruptible_after(0.3):
56
+ ....: ignore = libgap([1000]*100000)
48
57
"""
49
58
cdef Obj l
50
- cdef GapElement elem
51
- cdef int i
59
+ cdef tuple gap_elements = tuple (x if isinstance (x, GapElement) else libgap(x) for x in sage_list)
60
+ cdef Py_ssize_t n = len (gap_elements), i
61
+
52
62
try :
53
63
GAP_Enter()
54
- l = GAP_NewPlist(0 )
55
-
56
- for i, x in enumerate (sage_list):
57
- if not isinstance (x, GapElement):
58
- elem = < GapElement> libgap(x)
59
- else :
60
- elem = < GapElement> x
61
-
62
- GAP_AssList(l, i + 1 , elem.value)
64
+ l = GAP_NewPlist(n)
65
+ for i in range (n):
66
+ GAP_AssList(l, i + 1 , (< GapElement> gap_elements[i]).value)
63
67
return l
64
68
finally :
65
69
GAP_Leave()
You can’t perform that action at this time.
0 commit comments