Random musings

January 12, 2004

Gnu Multiprecision library bindings in Python
The gmpy module contains bindings for the gnu multiprecision library. The release notes say that it only works for Python 2.3, but I successfully got it to work on Python 2.2. Way, way cool.

For example, the following is an implementation of the Lucas-Lehmer test for Mersenne primes:

def lucas(p):
    "Test whether 2^p-1 is a Mersenne prime"
    s = 4
    val = pow(2,p)-1
    for i in range(3,p+1): s = (s*s-2)%val
    return not s

Using normal python long integers, this routine is an interesting toy, but not much else. However, with the gmpy libraries, you can grind away until your Powerbook G4 burns your lap:

def lucas_gmp(p):
    "Test whether 2^p-1 is a Mersenne prime"
    from gmpy import mpz
    s = mpz('4')
    val = pow(2,p)-1
    for i in range(3,p+1): s = (s*s-2)%val
    return not s

Way to go, Alex and Gustavo!

Nova episode on Mars Spirit
Just watched the recent Nova episode on the recentMars Spirit landing. Almost didn’t watch it, since I thought I knew everything about the mission, but was incredibly moved by the episode. If you haven’t seen it, track it down.

Pie-thon
You just have to love the Pie-Thon which pits the Python interpreter against Parrot, which started as an April Fools Joke. Guido doesn’t seem to be particularly worried, but he may be suprised. What’s good for Python is good for me, and this is very good for python.

Hydrogen economy criticized?
The current issue of the The Utne Reader has a reprint of an article by David Morris from Alternet critical of the hydrogen economy (paid subscription required, but the author voices similar views here.

One of the central points of Morris’ criticism is that the hydrogen economy is not in general a renewable technology, and that lots of hydrocarbons will need to be reformed to produce hydrogen gas. But one thing that Morris fails to take into account is that methane is currently a waste product of petroleum drilling: lots of methane is produced by drilling for oil, but since methane is a gas, and thus expensive to transport, it is usually flared at the oil field rather than being used for fuel. Despite a great deal of effort in the chemical community via Fischer-Tropsch catalysis or low-temperature methane-to-methanol catalysts, there is still no efficient way of using methane produced in this manner other than reforming to produce hydrogen and carbon monoxide (“town gas” or “syn gas”).

Reforming may not be the ultimate answer, but if you’re going to release the carbon from methane into the atmosphere, why not get some energy out of it first?

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: