Mark Dickinson added the comment:

I think this is mostly unavoidable: cmath.log(z, 10) is a compound operation 
that does the equivalent of cmath.log(z) / cmath.log(10), while cmath.log10 is 
doing everything at once.

If anything, this is a problem in how complex division is done: it's arguable 
that division by a complex number with zero imaginary part should be 
special-cased here.

>>> inf = float('inf')
>>> z = complex(-0.0, -inf)
>>> cmath.log(10)
(2.302585092994046+0j)
>>> cmath.log(z)
(inf-1.5707963267948966j)
>>> cmath.log(z) / cmath.log(10)
(inf+nanj)

A simpler example just involving division:

>>> complex(2.0, inf) / 2.0   # expect 1 + infj.
(nan+infj)

----------

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

Reply via email to