Skip to content

Commit c80cc11

Browse files
author
Release Manager
committed
gh-35805: gap: use libgap API for int conversion URL: #35805 Reported by: Max Horn Reviewer(s): Frédéric Chapoton
2 parents 6b6475d + 9775853 commit c80cc11

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
@@ -34,11 +34,6 @@ cdef extern from "gap/calls.h" nogil:
3434
Obj CALL_XARGS(Obj f, Obj args) # more than 6 arguments
3535

3636

37-
cdef extern from "gap/intobj.h" nogil:
38-
Obj INTOBJ_INT(Int)
39-
Int INT_INTOBJ(Obj)
40-
41-
4237
cdef extern from "gap/libgap-api.h" nogil:
4338
"""
4439
#define sig_GAP_Enter() {int t = GAP_Enter(); if (!t) sig_error();}
@@ -78,6 +73,8 @@ cdef extern from "gap/libgap-api.h" nogil:
7873

7974
bint GAP_IsInt(Obj)
8075
bint GAP_IsSmallInt(Obj)
76+
Obj GAP_NewObjIntFromInt(Int val)
77+
Int GAP_ValueInt(Obj)
8178

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

0 commit comments

Comments
 (0)