Skip to content

isprime never finishes with cypari2, but finishes in pari/gp terminal #183

@tkoz0

Description

@tkoz0

While proving primality for some large numbers, I observed that cypari2 would stay stuck on them but they would complete successfully in the PARI/GP interactive terminal. See the bottom for one such prime (1839 digits). The PARI/GP terminal takes about 10-15 minutes on a laptop CPU (i5-8265U) and the cypari2 usage does not finish even after letting it run for a whole day, although it appears to stop using CPU after about 10-15 minutes.

I am running the latest cypari2 version 2.2.2 on Ubuntu 24.04.

In the PARI/GP terminal, run the following (note: the memory limits are significantly higher than is absolutely necessary for my example number):

N = <the number provided below>
default(parisizemax,2^32)
default(threadsizemax,2^28)
setrand(1000003)
isprime(N)

In Python3, run the following

import cypari2
pari = cypari2.Pari()
pari.allocatemem(sizemax=2**32)
pari.default('parisizemax',2**32)
pari.default('threadsizemax',2**28)
pari.setrand(1000003)
N = <the number provided below>
pari.isprime(N)

Large prime (1839 digits):
109825974224435350133717197107995466726995520026699051804185890116378617744016694443041551645154404741677216340111030759361299985733609835807192624590123173334026995185998143424226221051168300301869899357528426186691239274674950680240193471837969771764683585147124761974334996671577199383740330005502422944872633704494707756324120977196202848388427774271567961069764227590573883760406144686655509905620362776527973036471982464334700458151652038804744986670395683162307240271333139933777501710377246354060165552468426299293531672480211636036032080269534477574140326842323040022625388507632397349225798352217381577945246933938209684008704905587611200118319681763090534370969637871088883005417001711153006530137101463824362473859934638993990705396270707613267585244516452837359336442452457808908796350917320670284844744535434898119971907355382598383856003165995713598231630550007121537923234420579701666626062905686164770027723236211012189670837723547510075401671318364139383527942996605332928192932684098093144653436739452907542058840907550639691132372400152928374252610987113339897533514024761426497425585029188513366152320401589887475883969541252906268147851061062946708066751550887831418606640877550141714408797825833586254802008905277303496311640598881478574064572287242847835697880075025527668426634050960466765171441224432595018236390699725423872186603733040270572507156698325392648318390068762168911015990369926865787355294159194431008017967079796579209701603067447514997371793876085238687589819487980345188562994152654103540035014507540860195432524802459319841659938342184383846624772822008947412544140657664200932225719195093011355362571352452570912007696160084192712332076076659971304739328477375493043578235007819831069651290148469893718347526131076775554856399762225169160568188715571130197938959819585717921574302983566677628869

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions