def test_pure_is_prime_for_sieves(self): for i in [10, 100, 1000, 10000]: sieve = _prime_sieve.make_prime_sieve(i) odds = [] for x in sieve: if not math._pure_is_prime(x, _sieve=[2, 3]): odds.append(x) self.assertEqual(odds, [])
from pprint import pprint header = '''\ #/usr/bin/env python # -*- coding: utf-8 -*- # Automatically-generated by dump_primes.py # # Copyright 2012 Google Inc. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Precomputed prime sieve for faster lookups.""" ''' print(header) a = set(make_prime_sieve(9999)) sys.stdout.write("SIEVE = ") pprint(a)