gmpy moving to code.google.com

Alex Martelli aleaxit at gmail.com
Tue Feb 27 10:33:55 EST 2007


On Feb 27, 2007, at 2:59 AM, Daniel Nogradi wrote:

> Hi Alex,
>
> I did another test, this time with python 2.4 on suse and things are
> worse than in the previous case (which was python 2.5 on fedora 3),
> ouput of 'python gmp_test.py' follows:

Interesting!  gmpy interacts with decimal.Decimal by "monkey- 
patching" that class on the fly; clearly the monkey-patching isn't  
working with 2.4 on SuSE, so all the addition attempts are failing  
(all 6 of them).

So the issue is finding out why this strategy is failing there, while  
succeeding on other Linux distros, Mac, and Windows.

To that end, I have added a feature in the latest svn trunk (revision  
11) to set gmpy's own options.debug flag from an environment variable  
named GMPY_DEBUG at startup (if that environment variable is set).

If you could please svn up and rebuild, then running with GMPY_DEBUG  
set in the environment should give something like:

brain:~/gmpy alex$ GMPY_DEBUG=1 python -c 'import gmpy' 2>&1 | tail -5
mp_allocate( 4->8 )
mp_allocate( 4->8 ) ->0x60b8b0
gmpy_module at 0x63390
gmpy_module imported decimal OK
gmpy_module tweaked decimal OK

This is the expected behavior when module decimal is present, while,  
when it's absent, you should see something like:

brain:~/gmpy alex$ GMPY_DEBUG=1 python2.3 -c 'import gmpy' 2>&1 |  
tail -5
Initing new not in zcache
mp_allocate( 4->8 )
mp_allocate( 4->8 ) ->0x3017d0
gmpy_module at 0x6de70
gmpy_module could not import decimal

In each case, what matters is the last line or two after "gmpy_module  
at" -- the rest of the copious debugging output is irrelevant here.

Module decimal is expected to be present from 2.4 forward (though it  
could also be explicitly installed on 2.3).  However, from the test  
failures you report, it looks like SuSE's 2.4 does not have decimal  
available for importing when gmpy is starting up -- so I'd like to  
confirm that first.

If it's confirmed, it will be interesting to discover how this  
happens (but that requires a SuSE installation, which I don't have)  
and secondarily what is gmpy to do about it -- maybe offer a warning  
on startup when module decimal is unexpectedly not importable but  
then skip the relevant unittests in that case?  (Note that the tests  
ARE already skipped if module decimal is not importable _at test  
time_ -- what's really weird is that apparently on SuSE decimal CAN  
be imported by the tests but CANNOT be imported earlier while gmpy is  
loading, which is truly puzzling).

I'd appreciate reports about this behavior on as many Python/Linux  
installations as possible -- yours, of course (to check my guess that  
the problem is that decimal can't be imported while gmpy is loading),  
but also others' (to see how widespread the problem is, etc, etc).

Thanks again for reporting this, and thanks in advance to anybody  
who'll lend a hand in tracking down this little strangeness!!!


Alex




More information about the Python-list mailing list