Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmath.log doesn't have the same interface as math.log. #39404

Closed
jemfinch mannequin opened this issue Oct 14, 2003 · 6 comments
Closed

cmath.log doesn't have the same interface as math.log. #39404

jemfinch mannequin opened this issue Oct 14, 2003 · 6 comments
Assignees
Labels
stdlib Python modules in the Lib dir

Comments

@jemfinch
Copy link
Mannequin

jemfinch mannequin commented Oct 14, 2003

BPO 823209
Nosy @rhettinger, @gaul

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = 'https://github.com/rhettinger'
closed_at = <Date 2004-06-14.07:43:31.000>
created_at = <Date 2003-10-14.04:23:56.000>
labels = ['library']
title = "cmath.log doesn't have the same interface as math.log."
updated_at = <Date 2004-06-14.07:43:31.000>
user = 'https://bugs.python.org/jemfinch'

bugs.python.org fields:

activity = <Date 2004-06-14.07:43:31.000>
actor = 'rhettinger'
assignee = 'rhettinger'
closed = True
closed_date = None
closer = None
components = ['Library (Lib)']
creation = <Date 2003-10-14.04:23:56.000>
creator = 'jemfinch'
dependencies = []
files = []
hgrepos = []
issue_num = 823209
keywords = []
message_count = 6.0
messages = ['18621', '18622', '18623', '18624', '18625', '18626']
nosy_count = 3.0
nosy_names = ['rhettinger', 'gaul', 'jemfinch']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = None
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue823209'
versions = []

@jemfinch
Copy link
Mannequin Author

jemfinch mannequin commented Oct 14, 2003

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.

@jemfinch jemfinch mannequin closed this as completed Oct 14, 2003
@jemfinch jemfinch mannequin assigned rhettinger Oct 14, 2003
@jemfinch jemfinch mannequin added the stdlib Python modules in the Lib dir label Oct 14, 2003
@jemfinch jemfinch mannequin closed this as completed Oct 14, 2003
@jemfinch jemfinch mannequin assigned rhettinger Oct 14, 2003
@jemfinch jemfinch mannequin added the stdlib Python modules in the Lib dir label Oct 14, 2003
@gaul
Copy link
Mannequin

gaul mannequin commented Oct 18, 2003

Logged In: YES
user_id=139865

See patch bpo-826074 for a fix.

@rhettinger
Copy link
Contributor

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).

@gaul
Copy link
Mannequin

gaul mannequin commented Oct 27, 2003

Logged In: YES
user_id=139865

Base 2 logarithms are somewhat common.

@jemfinch
Copy link
Mannequin Author

jemfinch mannequin commented Oct 27, 2003

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).

@rhettinger
Copy link
Contributor

Logged In: YES
user_id=80475

Applied Andrew Gaul's patch (with minor modifications) as
Modules/cmathmodule.c 2.33

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir
Projects
None yet
Development

No branches or pull requests

1 participant