~mdw
/
catacomb-python
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
key.c: Complain about duplicate subkeys passed to `KeyDataStructured'.
[catacomb-python]
/
pock
diff --git
a/pock
b/pock
index
377b811
..
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.
@@
-218,8
+222,10
@@
class Sieve (object):
## Figure out the number of bits in a (nonnegative) primitive `int'. We'll
## use a list of these as our sieve.
## Figure out the number of bits in a (nonnegative) primitive `int'. We'll
## use a list of these as our sieve.
+ try: _MAX = SYS.maxint
+ except AttributeError: _MAX = SYS.maxsize
_NBIT = 15
_NBIT = 15
- while
type(1 << (_NBIT + 1)) == int
: _NBIT += 1
+ while
1 << (_NBIT + 1) < _MAX
: _NBIT += 1
def __init__(me, limit):
"""
def __init__(me, limit):
"""
@@
-236,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]
@@
-279,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.
@@
-896,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)