Issue 823209: cmath.log doesn't have the same interface as math.log. (original) (raw)

Created on 2003-10-14 04:23 by jemfinch, last changed 2022-04-10 16:11 by admin. This issue is now closed.

Messages (6)
msg18621 - (view) Author: Jeremy Fincher (jemfinch) Date: 2003-10-14 04:23
Somewhere along the way, math.log gained an optional "base" argument. cmath.log is still missing it. >>> print math.log.__doc__ log(x[, base]) -> the logarithm of x to the given base. If the base not specified, returns the natural logarithm (base e) of x. >>> print cmath.log.__doc__ log(x) Return the natural logarithm of x.
msg18622 - (view) Author: Andrew Gaul (gaul) Date: 2003-10-18 18:42
Logged In: YES user_id=139865 See patch #826074 for a fix.
msg18623 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2003-10-27 19:44
Logged In: YES user_id=80475 I can fix this if necessary. My question is whether it should be done. On the one hand, it is nice to have the two interfaces as symmetrical as possible. OTOH, I'm not aware of any use cases for log(z, b).
msg18624 - (view) Author: Andrew Gaul (gaul) Date: 2003-10-27 20:20
Logged In: YES user_id=139865 Base 2 logarithms are somewhat common.
msg18625 - (view) Author: Jeremy Fincher (jemfinch) Date: 2003-10-27 22:03
Logged In: YES user_id=99508 In my particular usecase, I define an environment in which people can execute mathematical statements like so: _mathEnv = {'__builtins__': new.module('__builtins__'), 'i': 1j} _mathEnv.update(math.__dict__) _mathEnv.update(cmath.__dict__) As you can see, the cmath definitions shadow the math definitions, and thus I lose the useful ability to offer users a log with a base (which those that know Python expect to work). That's at least my particular use case. In this particular instance, since I don't want to allow the users to cause the application to consume arbitrary amounts of memory, I can't allow integer arithmetic (because of the crazy int/long unification that left people who wanted computationall bounded arithmetic with no choice but to implement a fixed-size integer type or use float/complex instead ;)) so I use complex objects everywhere, and math.log can't operate on complex objects (even those that have no imaginary component).
msg18626 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2004-06-14 07:43
Logged In: YES user_id=80475 Applied Andrew Gaul's patch (with minor modifications) as Modules/cmathmodule.c 2.33
History
Date User Action Args
2022-04-10 16:11:43 admin set github: 39404
2003-10-14 04:23:56 jemfinch create