Skip to content

Issues with request rate in robotparser #75842

Closed

Description

@serhiy-storchaka
BPO 31661
Nosy @berkerpeksag, @serhiy-storchaka
Superseder
  • bpo-31325: req_rate is a namedtuple type rather than instance
  • 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 = None
    closed_at = <Date 2017-10-02.10:17:25.436>
    created_at = <Date 2017-10-02.06:14:07.107>
    labels = ['3.7', 'type-bug', 'library']
    title = 'Issues with request rate in robotparser'
    updated_at = <Date 2017-10-02.10:32:24.614>
    user = 'https://github.com/serhiy-storchaka'

    bugs.python.org fields:

    activity = <Date 2017-10-02.10:32:24.614>
    actor = 'serhiy.storchaka'
    assignee = 'none'
    closed = True
    closed_date = <Date 2017-10-02.10:17:25.436>
    closer = 'berker.peksag'
    components = ['Library (Lib)']
    creation = <Date 2017-10-02.06:14:07.107>
    creator = 'serhiy.storchaka'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 31661
    keywords = []
    message_count = 5.0
    messages = ['303508', '303509', '303510', '303526', '303529']
    nosy_count = 3.0
    nosy_names = ['berker.peksag', 'serhiy.storchaka', 'XapaJIaMnu']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = 'resolved'
    status = 'closed'
    superseder = '31325'
    type = 'behavior'
    url = 'https://bugs.python.org/issue31661'
    versions = ['Python 3.6', 'Python 3.7']

    Activity

    1. serhiy-storchaka commented on Oct 2, 2017

      @serhiy-storchaka
      MemberAuthor

      There are issues in implementing support of request rate in robotparser.

          req_rate = collections.namedtuple('req_rate',
                                            'requests seconds')
          entry.req_rate = req_rate
          entry.req_rate.requests = int(numbers[0])
          entry.req_rate.seconds = int(numbers[1])

      First, a new namedtuple type is created for every entry. This is slow even with recent namedtuple optimizations, and is much slower in 3.6. This wastes a memory, since new type is created for every entry. This is definitely wrong, since req_rate is set to a namedtuple type instead of namedtuple instance. And there is a question why a namedtuple is used here at all. Other classes in this module are not namedtuples.

    2. added
      3.7 (EOL)
      stdlib
      type-bug
      on Oct 2, 2017
    3. XapaJIaMnu commented on Oct 2, 2017

      XapaJIaMnumannequin
      Mannequin

      Hey Serhiy,

      The use of namedtuple was requested specifically at a review, I didn't implement it like this initially: https://bugs.python.org/review/16099/#ps6205

      I wasn't aware of the performance implications. Could you please explain to me the type vs instance in terms of performance (or point me to a resource, a quick googling didn't yield anything? How was I supposed to have coded it properly?

      Cheers,

      Nick

    4. serhiy-storchaka commented on Oct 2, 2017

      @serhiy-storchaka
      MemberAuthor

      For the performance of namedtuple type creation see bpo-28638 and https://mail.python.org/pipermail/python-dev/2017-July/148592.html. For difference between types and instance see https://docs.python.org/3/tutorial/classes.html.

    5. berkerpeksag commented on Oct 2, 2017

      @berkerpeksag
      Member

      Thanks for the report. Your analysis is correct and this is a duplicate of bpo-31325. I'll take care of the PR 3259.

    6. serhiy-storchaka commented on Oct 2, 2017

      @serhiy-storchaka
      MemberAuthor

      Oh, I missed this. My report is based on the same comment on news.ycombinator.com.

    7. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      3.7 (EOL)stdlibtype-bug

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions