~mdw
/
catacomb-python
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
key.c: Populate `KeyDataStructured' from the keywords.
[catacomb-python]
/
pock
diff --git
a/pock
b/pock
index
7112530
..
5d7cc50
100644
(file)
--- a/
pock
+++ b/
pock
@@
-27,7
+27,7
@@
###--------------------------------------------------------------------------
### Imported modules.
###--------------------------------------------------------------------------
### Imported modules.
-from sys import argv, stdin, stdout, stderr
+
import sys as SYS;
from sys import argv, stdin, stdout, stderr
import os as OS
import itertools as I
import math as M
import os as OS
import itertools as I
import math as M
@@
-35,6
+35,10
@@
import optparse as OP
import catacomb as C
import catacomb as C
+if SYS.version_info >= (3,):
+ xrange = range
+ range = lambda *args: list(xrange(*args))
+
###--------------------------------------------------------------------------
### Utilities.
###--------------------------------------------------------------------------
### Utilities.
@@
-238,8
+242,8
@@
class Sieve (object):
me.limit = limit
## Calculate the size of sieve we'll need and initialize the bit list.
me.limit = limit
## Calculate the size of sieve we'll need and initialize the bit list.
- n = (limit - 2)/2
- sievesz = (n + me._NBIT - 1)/me._NBIT
+ n = (limit - 2)/
/
2
+ sievesz = (n + me._NBIT - 1)/
/
me._NBIT
me._sievemax = sievesz*me._NBIT
me._bits = sievesz*[0]
me._sievemax = sievesz*me._NBIT
me._bits = sievesz*[0]
@@
-281,7
+285,7
@@
def initsieve(sievebits):
global SIEVE
if SIEVE is not None: raise ValueError('sieve already defined')
if sievebits < 6: sievebits = 6
global SIEVE
if SIEVE is not None: raise ValueError('sieve already defined')
if sievebits < 6: sievebits = 6
- SIEVE = Sieve(1 << (sievebits + 1)/2)
+ SIEVE = Sieve(1 << (sievebits + 1)/
/
2)
###--------------------------------------------------------------------------
### Primality checking.
###--------------------------------------------------------------------------
### Primality checking.
@@
-898,7
+902,7
@@
def gen(nbits, label = None, p = ProgressReporter()):
Give it the LABEL, and report progress to P.
"""
Give it the LABEL, and report progress to P.
"""
- if SIEVE.limit >> (nbits + 1)/2: g = gen_small
+ if SIEVE.limit >> (nbits + 1)/
/
2: g = gen_small
else: g = gen_pock
return g(nbits, label = label, p = p)
else: g = gen_pock
return g(nbits, label = label, p = p)