[Python-ideas] Add the imath module

David Mertz mertz at gnosis.cx
Thu Jul 12 08:15:39 EDT 2018


On Thu, Jul 12, 2018, 7:56 AM Serhiy Storchaka <storchaka at gmail.com> wrote:

> * isprime(n)
> Tests if n is a prime number.
>

How would you test this? The Miller-Rabin Primality test? For large
numbers, iterating through candidate prime divisors is pricey.

* primes()
> Returns an iterator of prime numbers: 2, 3, 5, 7, 11, 13,...
>

How would you implements this? Sieve of Eratosthenes is really fun to show
students as a Python generator function. But the cached primes DO grow
unboundedly as you utilize the generator. Wheel factorization as first
pass? Do you cached the first N primes so the each instance of iterator can
provide initial elements much faster? What is N?

>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180712/7cca313f/attachment.html>


More information about the Python-ideas mailing list