Mark Dickinson added the comment:

Trent, many thanks for the report and analysis.  The LOG1P_DROPS_ZERO_SIGN 
hackery was a result of a previous attempt to 'fix' the tests on another 
platform whose log1p didn't preserve zero signs.  But now that this behaviour 
has emerged on OS X too, I think it might be time to fix this in the Python 
core code (i.e., add a workaround for the buggy OS behaviour) instead of trying 
to make the tests pass again.

Attached is a patch that adds a workaround for this on all platforms that have 
a system log1p.  I was originally thinking of adding this workaround only on OS 
X (so as not to unnecessarily punish those platforms that get it right), but 
after running some timings (see below) it seems that the workaround is 
insignificant performance-wise, so we might as well keep things simple and add 
it on all platforms.

Trent, if you have time, please could you try this patch on OS X 10.8 and see 
if it fixes all the test_cmath and test_math failures?




Some timings on OS X 10.6.

Current default branch (pass value directly onto system log1p):

iwasawa:cpython mdickinson$ ./python.exe -m timeit -s 'from math import log1p; 
x = 2.3' 'log1p(x)'
10000000 loops, best of 3: 0.0685 usec per loop

With the attached patch (do zero check, then pass value directly onto system 
log1p):

iwasawa:cpython mdickinson$ ./python.exe -m timeit -s 'from math import log1p; 
x = 2.3' 'log1p(x)'
10000000 loops, best of 3: 0.0686 usec per loop

----------
Added file: http://bugs.python.org/file26884/log1p_sign_workaround.patch

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue15477>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to