Skip to content

Fix statistics.py after the Decimal.as_integer_ratio() changeΒ #70162

Closed

Description

@skrah
mannequin
BPO 25974
Nosy @rhettinger, @terryjreedy, @mdickinson, @abalkin, @stevendaprano, @skrah, @berkerpeksag, @serhiy-storchaka
Files
  • statistics_as_integer_ratio.diff
  • 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/stevendaprano'
    closed_at = <Date 2016-05-06.12:02:09.068>
    created_at = <Date 2015-12-29.12:49:31.259>
    labels = ['type-bug', 'library', 'release-blocker']
    title = 'Fix statistics.py after the Decimal.as_integer_ratio() change'
    updated_at = <Date 2016-05-06.12:02:09.066>
    user = 'https://github.com/skrah'

    bugs.python.org fields:

    activity = <Date 2016-05-06.12:02:09.066>
    actor = 'berker.peksag'
    assignee = 'steven.daprano'
    closed = True
    closed_date = <Date 2016-05-06.12:02:09.068>
    closer = 'berker.peksag'
    components = ['Library (Lib)']
    creation = <Date 2015-12-29.12:49:31.259>
    creator = 'skrah'
    dependencies = []
    files = ['41446']
    hgrepos = []
    issue_num = 25974
    keywords = ['patch', '3.5regression']
    message_count = 7.0
    messages = ['257178', '257184', '257186', '257190', '257210', '262826', '264968']
    nosy_count = 10.0
    nosy_names = ['rhettinger', 'terry.reedy', 'mark.dickinson', 'belopolsky', 'steven.daprano', 'skrah', 'python-dev', 'berker.peksag', 'serhiy.storchaka', 'johnwalker']
    pr_nums = []
    priority = 'release blocker'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue25974'
    versions = ['Python 3.6']

    Activity

    1. skrah commented on Dec 29, 2015

      skrahmannequin
      MannequinAuthor

      Here's a fix for the fallout from bpo-25928. I've set it to
      release blocker to make sure we don't forget.

    2. added
      stdlibStandard Library Python modules in the Lib/ directory
      type-bugAn unexpected behavior, bug, or error
      on Dec 29, 2015
    3. serhiy-storchaka commented on Dec 29, 2015

      @serhiy-storchaka
      Member

      LGTM.

      I haven't tested that "type(x) is float or type(x) is Decimal" is faster than alternatives ("type(x) in (float, Decimal)", or "isinstance(x, (float, Decimal))", or "hasattr(x, 'as_integer_ratio')") and believe you have tested this.

    4. skrah commented on Dec 29, 2015

      skrahmannequin
      MannequinAuthor

      No, I haven't done any benchmarks. In a quick test type(x) == float
      does not seem any faster than isinstance(x, float), so perhaps we
      could reduce the try/except complexity.

    5. skrah commented on Dec 29, 2015

      skrahmannequin
      MannequinAuthor

      The clear winner for float and Decimal is hasattr(x, 'as_integer_ratio').
      The other types are a bit disadvantaged if the lookup fails, but they
      go through additional try/excepts anyway.

    6. serhiy-storchaka commented on Dec 29, 2015

      @serhiy-storchaka
      Member

      I believe the current code is well-weighed compromise that optimize different cases ranged for their frequency of occurrence (floats, ints, decimals, fractions, subclasses of int, float, etc and independed numeric types). And new addition unlikely will change the balance too much, but we have to be aware. If Steven have no something to add, the patch LGTM.

    7. skrah commented on Apr 3, 2016

      skrahmannequin
      MannequinAuthor

      Ping. Just a reminder that it would be nice to get this into 3.6-alpha-1. :)

    8. berkerpeksag commented on May 6, 2016

      @berkerpeksag
      Member

      statistics_as_integer_ratio.diff has been committed in 7b2fafd78c1d.

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

    Labels

    release-blockerstdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions