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

Clarify that the itertools pure python equivalents are only approximate. #70114

Closed
tfeldmann mannequin opened this issue Dec 22, 2015 · 10 comments
Closed

Clarify that the itertools pure python equivalents are only approximate. #70114

tfeldmann mannequin opened this issue Dec 22, 2015 · 10 comments
Assignees
Labels
docs Documentation in the Doc dir type-bug An unexpected behavior, bug, or error

Comments

@tfeldmann
Copy link
Mannequin

tfeldmann mannequin commented Dec 22, 2015

BPO 25926
Nosy @rhettinger, @bitdancer, @tfeldmann, @Shredder13
Files
  • issue25926.diff: diff for change in itertools.rst
  • 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 2016-05-28.07:27:44.876>
    created_at = <Date 2015-12-22.17:40:36.188>
    labels = ['type-bug', 'docs']
    title = 'Clarify that the itertools pure python equivalents are only approximate.'
    updated_at = <Date 2016-05-28.11:26:07.030>
    user = 'https://github.com/tfeldmann'

    bugs.python.org fields:

    activity = <Date 2016-05-28.11:26:07.030>
    actor = 'python-dev'
    assignee = 'rhettinger'
    closed = True
    closed_date = <Date 2016-05-28.07:27:44.876>
    closer = 'rhettinger'
    components = ['Documentation']
    creation = <Date 2015-12-22.17:40:36.188>
    creator = 'tfeldmann'
    dependencies = []
    files = ['43026']
    hgrepos = ['344', '345']
    issue_num = 25926
    keywords = ['patch']
    message_count = 10.0
    messages = ['256847', '256848', '265835', '265840', '266478', '266480', '266542', '266543', '266544', '266547']
    nosy_count = 6.0
    nosy_names = ['rhettinger', 'r.david.murray', 'python-dev', 'Winterflower', 'tfeldmann', 'Nofar Schnider']
    pr_nums = []
    priority = 'low'
    resolution = 'fixed'
    stage = None
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue25926'
    versions = ['Python 2.7', 'Python 3.5']

    @tfeldmann
    Copy link
    Mannequin Author

    tfeldmann mannequin commented Dec 22, 2015

    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.

    @tfeldmann tfeldmann mannequin added interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error labels Dec 22, 2015
    @bitdancer
    Copy link
    Member

    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.

    @Winterflower
    Copy link
    Mannequin

    Winterflower mannequin commented May 18, 2016

    Should 'roughly equivalent to' be added as a note to the docs?

    @rhettinger
    Copy link
    Contributor

    I'm okay with changing the docs to "roughly equivalent to". That will help prevent the occasional misreading as "precisely equivalent in every respect".

    @Shredder13
    Copy link
    Mannequin

    Shredder13 mannequin commented May 27, 2016

    Issue bpo-25926
    Changed all "equivalent to" occurrences to "roughly equivalent to"

    @Shredder13
    Copy link
    Mannequin

    Shredder13 mannequin commented May 27, 2016

    Attached a diff
    All occurrences of "equivalent to" are switched to "roughly equivalent to"

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented May 28, 2016

    New changeset 613314c3f9ed by Raymond Hettinger in branch '3.5':
    bpo-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':
    bpo-25926: Clarify that the pure python equivalents are only approximate.
    https://hg.python.org/cpython/rev/e67e970de54a

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented May 28, 2016

    New changeset f66c30f66235 by Raymond Hettinger in branch '2.7':
    bpo-25926: Clarify that the pure python equivalents are only approximate.
    https://hg.python.org/cpython/rev/f66c30f66235

    @rhettinger
    Copy link
    Contributor

    Nofar, thanks for the patch.

    @rhettinger rhettinger added docs Documentation in the Doc dir and removed interpreter-core (Objects, Python, Grammar, and Parser dirs) labels May 28, 2016
    @rhettinger rhettinger changed the title problems with "times" keyword in itertools.repeat Clarify that the itertools pure python equivalents are only approximate. May 28, 2016
    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented May 28, 2016

    New changeset 35fa2ec1f237 by Serhiy Storchaka in branch 'default':
    Merge heads (issue bpo-25926).
    https://hg.python.org/cpython/rev/35fa2ec1f237

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    docs Documentation in the Doc dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants