Open 47ec2b77-7255-4a48-8516-146951dea49a opened 2 years ago
The math module documentation says:
Except when explicitly noted otherwise, all return values are floats.
But this code returns an integer:
from math import prod; prod((1,2,3))
Doc should "explicitly note otherwise" here, I imagine. The issue being wanting to know that the result on all-integer input will be an exact (integer) value not a floating value.
I'll add a note that the output type is determined by the input type.
I would like to try working this issue. Is it still available? It would be my first ever contribution to Python.
@rhettinger, I think that the prod docs does "explicitly notes": "Calculate the product of all the elements in the input iterable." - and there is no doubts about the output type. Other cases (e.g. math.perm) are also very clear as exceptions.
@ChanceCarmichael, are you still interested? Then go ahead. I suggest you to follow first @rhettinger comment.
But I'm not sure if it's a good solution. Same is, for example, not explicitly documented for the math.sumprod().
Lets instead replace misleading (OP) sentence "Except when explicitly noted otherwise, all return values are floats." by something like "Return values for module functions either floats, or determined from acceptable types of arguments."
a little pr: https://github.com/python/cpython/pull/124297
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: ```python assignee = 'https://github.com/rhettinger' closed_at = None created_at =
labels = ['type-bug', 'docs']
title = 'math.prod can return integers (contradicts doc)'
updated_at =
user = 'https://github.com/outofmbufs'
```
bugs.python.org fields:
```python
activity =
actor = 'rhettinger'
assignee = 'rhettinger'
closed = False
closed_date = None
closer = None
components = ['Documentation']
creation =
creator = 'neilwebber'
dependencies = []
files = []
hgrepos = []
issue_num = 46828
keywords = []
message_count = 2.0
messages = ['413741', '413763']
nosy_count = 3.0
nosy_names = ['rhettinger', 'docs@python', 'neilwebber']
pr_nums = []
priority = 'low'
resolution = None
stage = None
status = 'open'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue46828'
versions = []
```
Linked PRs