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

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

Closed
skrah mannequin opened this issue Dec 29, 2015 · 7 comments
Closed

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

skrah mannequin opened this issue Dec 29, 2015 · 7 comments
Assignees
Labels
release-blocker stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@skrah
Copy link
Mannequin

skrah mannequin commented Dec 29, 2015

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']

    @skrah
    Copy link
    Mannequin Author

    skrah mannequin commented Dec 29, 2015

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

    @skrah skrah mannequin added the release-blocker label Dec 29, 2015
    @skrah skrah mannequin assigned stevendaprano Dec 29, 2015
    @skrah skrah mannequin added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Dec 29, 2015
    @serhiy-storchaka
    Copy link
    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.

    @skrah
    Copy link
    Mannequin Author

    skrah mannequin commented Dec 29, 2015

    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.

    @skrah
    Copy link
    Mannequin Author

    skrah mannequin commented Dec 29, 2015

    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.

    @serhiy-storchaka
    Copy link
    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.

    @skrah
    Copy link
    Mannequin Author

    skrah mannequin commented Apr 3, 2016

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

    @berkerpeksag
    Copy link
    Member

    statistics_as_integer_ratio.diff has been committed in 7b2fafd78c1d.

    @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
    release-blocker stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants