-
-
Notifications
You must be signed in to change notification settings - Fork 528
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
prime_range problem #7017
Comments
Author: kevin.stueve |
Reviewer: was |
This comment has been minimized.
This comment has been minimized.
comment:5
I haven't looked closely at the patch. The one quick note I can make is that it looks like a few uses of double-quotes should be changed to backquotes, i.e. everything that should appear as More important to me is the segfault. The problem is this: when I wrote this, I clearly only tested with large input on my 32-bit machine, where I'm getting the same behavior as Kevin -- the code converts the input to an int, which is sufficient to stop overly large input on a 32-bit machine, but fails horribly on a 64-bit machine. I think the segfault is coming from Pari trying to double its stack appropriately, maybe? There are a number of easy solutions, but I think the most robust would be to just hardcode an upper bound: if the user asks for a range with one of the parameters larger than our fixed bound, we should just fall back to a different method. The docs already say something about not using this with large input -- we just need to change that to say that it automatically switches algorithms for sufficiently large input. In fact, I think that if we do this, we don't even need the |
Attachment: 7017.patch.gz changed some double quotes to double backquotes |
comment:6
Changed some double quotes to double backquotes. |
comment:7
On my atom netbook with 1GB RAM I can't even use prime_range near 410**8 (and my virtual memory was thrashing for 310**8). I don't think a hard-coded limit is appropriate if what values are possible depends on how much RAM is available (should the limit be configurable?). Sebastian Pancratz suggested having the algorithm default be None, which would cause the algorithm to be automatically chosen. Yes, it would be better if it automatically selected the appropriate algorithm for the input. At a minimum, when prime_range with pari_primes fails, a message should be printed saying that the other algorithm is available. Unfortunately assuming the user will read the doc string when a function fails is not realistic. The patch I made also includes fixing a typo in a doc string in line 8605 (primes_up_to_n) of gen.pyx in the sage pari lib. Currently prime_range in fast_arith.pyx calls primes_up_to_n in gen.pyx, which calls pari(n).primepi(). I think this should be replaced with Sage's prime_pi, which is faster and works for larger input. Another bug, regarding Sage trac. I put the traceback in a special box. Yet this text above does not wrap. This text above should still be word wrapped.
|
comment:8
My attachment description is incomplete. I accidentally overwrote my old description. |
comment:9
I should construct ValueError(somestring), for Python 3 compatibility. |
Adds some docstring formatting and does a little Python 3 preparation. |
comment:10
Attachment: trac_7017-referee.patch.gz Good job. Looks good to me. This referee patch does a little bit of formatting tweaks. Please feel free to review or ignore the patch. |
Changed author from kevin.stueve to Kevin Stueve |
Changed reviewer from was to William Stein, Tim Dumol |
comment:11
So I'm happy for the code with the alternate algorithm to go in -- but it doesn't seem to address the segfault mentioned in the description. I'm happy to fix that soon, but can someone open a new ticket for it so we don't forget? Also, unless I'm missing something, the second hunk in the referee patch seems erroneous. I like the referee patch otherwise -- pretty documentation is always great. :) Kevin: for the record, we put human-readable names in Author: and Reviewer:, not trac usernames. (Did William review this, or was he intending to?) |
Attachment: trac_7017-referee.2.patch.gz Fixes a transposed word. Apply this referee patch on top of original patch (7017.patch) |
comment:12
Sorry about that. Here's the fix. |
comment:13
Positive review on Tim's patch. Great job! |
Merged: sage-4.3.1.rc1 |
comment:14
Attachment: trac_7017-ref3.patch.gz |
comment:15
It looks like this ticket was closed without resolving the segfault issue. I suppose that is valid because that issue is still open at #5943? |
I am having trouble with the following lines. I am on a
MacBook pro. kevin.stueve
Those two lines gave me a segfault on sage.math:
Minh Van Nguyen
CC: @craigcitro
Component: number theory
Keywords: prime_range, primes, prime number theory, prime
Author: Kevin Stueve
Reviewer: William Stein, Tim Dumol
Merged: sage-4.3.1.rc1
Issue created by migration from https://trac.sagemath.org/ticket/7017
The text was updated successfully, but these errors were encountered: