Skip to content

Commit 9775853

Browse files
committed
gap: use libgap API for int conversion
1 parent 3230f00 commit 9775853

File tree

3 files changed

+6
-15
lines changed

3 files changed

+6
-15
lines changed

src/sage/groups/perm_gps/permgroup_element.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ from sage.libs.gap.gap_includes cimport (UInt, UInt2, UInt4, T_PERM2, T_PERM4,
138138
from sage.libs.gap.util cimport initialize
139139
from sage.libs.gap.element cimport (GapElement, GapElement_List,
140140
GapElement_String, GapElement_Permutation, make_GapElement_Permutation)
141-
from sage.libs.gap.gap_includes cimport Obj, INT_INTOBJ, ELM_LIST
141+
from sage.libs.gap.gap_includes cimport Obj, GAP_ValueInt, ELM_LIST
142142

143143
import operator
144144

@@ -1361,7 +1361,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement):
13611361
assert vn <= self.n
13621362

13631363
for i in range(vn):
1364-
j = INT_INTOBJ(ELM_LIST(obj, i+1))
1364+
j = GAP_ValueInt(ELM_LIST(obj, i+1))
13651365
new.perm[i] = j - 1
13661366
for i in range(vn, self.n):
13671367
new.perm[i] = i

src/sage/libs/gap/element.pyx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -217,13 +217,7 @@ cdef Obj make_gap_integer(sage_int) except NULL:
217217
sage: libgap(1) # indirect doctest
218218
1
219219
"""
220-
cdef Obj result
221-
try:
222-
GAP_Enter()
223-
result = INTOBJ_INT(<int>sage_int)
224-
return result
225-
finally:
226-
GAP_Leave()
220+
return GAP_NewObjIntFromInt(<int>sage_int)
227221

228222

229223
cdef Obj make_gap_string(sage_string) except NULL:
@@ -1502,7 +1496,7 @@ cdef class GapElement_Integer(GapElement):
15021496
if ring is None:
15031497
ring = ZZ
15041498
if self.is_C_int():
1505-
return ring(INT_INTOBJ(self.value))
1499+
return ring(GAP_ValueInt(self.value))
15061500
else:
15071501
# TODO: waste of time!
15081502
# gap integers are stored as a mp_limb_t and we have a much more direct

src/sage/libs/gap/gap_includes.pxd

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,6 @@ cdef extern from "gap/calls.h" nogil:
4545
Obj CALL_XARGS(Obj f, Obj args) # more than 6 arguments
4646

4747

48-
cdef extern from "gap/intobj.h" nogil:
49-
Obj INTOBJ_INT(Int)
50-
Int INT_INTOBJ(Obj)
51-
52-
5348
cdef extern from "gap/libgap-api.h" nogil:
5449
"""
5550
#define sig_GAP_Enter() {int t = GAP_Enter(); if (!t) sig_error();}
@@ -79,6 +74,8 @@ cdef extern from "gap/libgap-api.h" nogil:
7974

8075
bint GAP_IsInt(Obj)
8176
bint GAP_IsSmallInt(Obj)
77+
Obj GAP_NewObjIntFromInt(Int val)
78+
Int GAP_ValueInt(Obj)
8279

8380
bint GAP_IsList(Obj lst)
8481
UInt GAP_LenList(Obj lst)

0 commit comments

Comments
 (0)