Since I did a year-long Senior Project in college about Gaussian primes, and am also a contented user of the Python language, I may perhaps be forgiven for posting the following. It's from Dr. Dobb's Python-URL! - weekly Python news and links [leave a comment if you want subscription info]:
When you are switching from, say, Java you will probably be surprised that in Python p = 2**24036583 - 1 is all it takes to calculate the largest known prime number to date. Printing p will also work out of the box, but may take a bit long. Tim Peters sketches the algorithm Python uses to generate the decimal representation of an integer and provides code that can handle very large numbers efficiently. See two usenet threads.On my machine, it takes a couple seconds to do the p = 2**24036583 - 1 assignment.
Out of interest, does it actually do the calculation when it does the assignment, or is it lazily evaluated in a background thread or something like that?
Posted by: David Cantrell | June 14, 2004 at 08:34 PM
I'm 99.999% sure it's actually doing the calculation. For one thing, Python has no facility to do that kind of thing "in a background thread" that I've ever heard of, and I probably qualify as an expert in the language. Moreover, after the initial assignment to p, I can do p % 2 and instantaneously get back the correct answer (1).
Posted by: Gary Robinson | June 14, 2004 at 09:04 PM