Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not assign clones to objects on the pari stack #113

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ on:
push:
tags:
- '*'
workflow_dispatch:
# Allow to run manually

jobs:
build:
Expand Down
9 changes: 9 additions & 0 deletions cypari2/gen.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1531,6 +1531,11 @@ cdef class Gen(Gen_base):

self.cache((i,j), x)
xt = x.ref_target()

if not is_universal_constant(x.g):
# Make sure that self is on the heap, before we assign a clone to it.
self.fixGEN()

set_gcoeff(self.g, i+1, j+1, xt)
return

Expand All @@ -1555,6 +1560,10 @@ cdef class Gen(Gen_base):

self.cache(i, x)
xt = x.ref_target()
if not is_universal_constant(x.g):
# Make sure that self is on the heap, before we assign a clone to it.
self.fixGEN()

if typ(self.g) == t_LIST:
listput(self.g, xt, i+1)
else:
Expand Down
6 changes: 5 additions & 1 deletion cypari2/pari_instance.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1298,6 +1298,10 @@ cdef class Pari(Pari_auto):
if len(entries) != m * n:
raise IndexError("len of entries (=%s) must be %s*%s=%s"%(len(entries),m,n,m*n))
k = 0

# Make sure that A is on the heap, before we assign clones to it.
A.fixGEN()

for i in range(m):
for j in range(n):
sig_check()
Expand All @@ -1318,7 +1322,7 @@ cdef class Pari(Pari_auto):

If the second argument `p` is specified, it must be a prime.
Then only the local information at `p` is computed and returned.

Examples:

>>> import cypari2
Expand Down