classification
Title: Clarify that the itertools pure python equivalents are only approximate.
Type: behavior Stage:
Components: Documentation Versions: Python 3.5, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: rhettinger Nosy List: Nofar Schnider, Winterflower, python-dev, r.david.murray, rhettinger, tfeldmann
Priority: low Keywords: patch

Created on 2015-12-22 17:40 by tfeldmann, last changed 2016-05-28 11:26 by python-dev. This issue is now closed.

Files
File name Uploaded Description Edit
issue25926.diff Nofar Schnider, 2016-05-27 06:11 diff for change in itertools.rst review
Repositories containing patches
https://hg.python.org/cpython
https://hg.python.org/cpython
Messages (10)
msg256847 - (view) Author: Thomas Feldmann (tfeldmann) Date: 2015-12-22 17:40
According to the docs `itertools.repeat(object[, times])` is equivalent to

```
def repeat(object, times=None):
    # repeat(10, 3) --> 10 10 10
    if times is None:
        while True:
            yield object
    else:
        for i in range(times):
            yield object
```

But it raises a TypeError when used this way:

```
Python 3.5.1 (default, Dec 10 2015, 10:34:07)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.1.76)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from itertools import repeat
>>> repeat('x', times=None)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'NoneType' object cannot be interpreted as an integer
```

The `times` keyword can be omitted but not explicitly set to None.
I checked with Python Versions 2.7 and 3.5.1 on Mac OS X and Windows 10.
msg256848 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2015-12-22 17:46
Huh.  I always thought the wording was "roughly equivalent to".  This is a consequence of C vs python, and is the reason the docstring uses the [] notation.
msg265835 - (view) Author: Camilla Montonen (Winterflower) Date: 2016-05-18 20:11
Should 'roughly equivalent to' be added as a note to the docs?
msg265840 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2016-05-19 01:17
I'm okay with changing the docs to "roughly equivalent to".  That will help prevent the occasional misreading as "precisely equivalent in every respect".
msg266478 - (view) Author: Nofar Schnider (Nofar Schnider) * (Python triager) Date: 2016-05-27 06:00
Issue #25926
Changed all "equivalent to" occurrences to "roughly equivalent to"
msg266480 - (view) Author: Nofar Schnider (Nofar Schnider) * (Python triager) Date: 2016-05-27 06:11
Attached a diff
All occurrences of "equivalent to" are switched to "roughly equivalent to"
msg266542 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-05-28 07:18
New changeset 613314c3f9ed by Raymond Hettinger in branch '3.5':
Issue 25926:  Clarify that the pure python equivalents are only approximate.
https://hg.python.org/cpython/rev/613314c3f9ed

New changeset e67e970de54a by Raymond Hettinger in branch 'default':
Issue 25926:  Clarify that the pure python equivalents are only approximate.
https://hg.python.org/cpython/rev/e67e970de54a
msg266543 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-05-28 07:26
New changeset f66c30f66235 by Raymond Hettinger in branch '2.7':
Issue 25926:  Clarify that the pure python equivalents are only approximate.
https://hg.python.org/cpython/rev/f66c30f66235
msg266544 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2016-05-28 07:27
Nofar, thanks for the patch.
msg266547 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-05-28 11:26
New changeset 35fa2ec1f237 by Serhiy Storchaka in branch 'default':
Merge heads (issue #25926).
https://hg.python.org/cpython/rev/35fa2ec1f237
History
Date User Action Args
2016-05-28 11:26:07python-devsetmessages: + msg266547
2016-05-28 07:27:44rhettingersetstatus: open -> closed
title: problems with "times" keyword in itertools.repeat -> Clarify that the itertools pure python equivalents are only approximate.
messages: + msg266544

components: + Documentation, - Interpreter Core
resolution: fixed
2016-05-28 07:26:51python-devsetmessages: + msg266543
2016-05-28 07:18:42python-devsetnosy: + python-dev
messages: + msg266542
2016-05-27 06:11:02Nofar Schnidersetfiles: + issue25926.diff
hgrepos: + hgrepo345
messages: + msg266480

keywords: + patch
2016-05-27 06:07:06Nofar Schnidersetfiles: - itertools.rst
2016-05-27 06:00:45Nofar Schnidersetfiles: + itertools.rst

nosy: + Nofar Schnider
messages: + msg266478

hgrepos: + hgrepo344
2016-05-19 01:17:50rhettingersetpriority: normal -> low

messages: + msg265840
2016-05-18 20:17:00serhiy.storchakasetassignee: rhettinger
2016-05-18 20:11:31Winterflowersetnosy: + Winterflower
messages: + msg265835
2015-12-22 17:46:32r.david.murraysetnosy: + rhettinger, r.david.murray
messages: + msg256848
2015-12-22 17:40:36tfeldmanncreate