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

Faster float.fromhex() #71192

Closed
serhiy-storchaka opened this issue May 12, 2016 · 6 comments
Closed

Faster float.fromhex() #71192

serhiy-storchaka opened this issue May 12, 2016 · 6 comments
Assignees
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) performance Performance or resource usage

Comments

@serhiy-storchaka
Copy link
Member

BPO 27005
Nosy @mdickinson, @serhiy-storchaka
Files
  • float_fromhex.patch
  • 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/serhiy-storchaka'
    closed_at = <Date 2016-05-12.07:22:17.741>
    created_at = <Date 2016-05-12.06:48:21.996>
    labels = ['interpreter-core', 'performance']
    title = 'Faster float.fromhex()'
    updated_at = <Date 2016-05-12.07:53:10.588>
    user = 'https://github.com/serhiy-storchaka'

    bugs.python.org fields:

    activity = <Date 2016-05-12.07:53:10.588>
    actor = 'serhiy.storchaka'
    assignee = 'serhiy.storchaka'
    closed = True
    closed_date = <Date 2016-05-12.07:22:17.741>
    closer = 'serhiy.storchaka'
    components = ['Interpreter Core']
    creation = <Date 2016-05-12.06:48:21.996>
    creator = 'serhiy.storchaka'
    dependencies = []
    files = ['42824']
    hgrepos = []
    issue_num = 27005
    keywords = ['patch']
    message_count = 6.0
    messages = ['265366', '265367', '265369', '265370', '265371', '265374']
    nosy_count = 3.0
    nosy_names = ['mark.dickinson', 'python-dev', 'serhiy.storchaka']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'performance'
    url = 'https://bugs.python.org/issue27005'
    versions = ['Python 3.6']

    @serhiy-storchaka
    Copy link
    Member Author

    Proposed patch makes float.fromhex() faster for exact float.

    $ ./python -m timeit -s "h = float.hex(1.23)" -- "float.fromhex(h)"

    Unpatched: 1000000 loops, best of 3: 0.886 usec per loop
    Patched: 1000000 loops, best of 3: 0.519 usec per loop

    @serhiy-storchaka serhiy-storchaka added interpreter-core (Objects, Python, Grammar, and Parser dirs) performance Performance or resource usage labels May 12, 2016
    @mdickinson
    Copy link
    Member

    LGTM

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented May 12, 2016

    New changeset 3b19660611a4 by Serhiy Storchaka in branch 'default':
    Issue bpo-27005: Optimized the float.fromhex() class method for exact float.
    https://hg.python.org/cpython/rev/3b19660611a4

    @serhiy-storchaka
    Copy link
    Member Author

    Thank you Mark.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented May 12, 2016

    New changeset 1bae2a6bb37c by Serhiy Storchaka in branch 'default':
    Issue bpo-27005: Fixed the call of PyObject_CallFunctionObjArgs().
    https://hg.python.org/cpython/rev/1bae2a6bb37c

    @serhiy-storchaka
    Copy link
    Member Author

    A mistake in using PyObject_CallFunctionObjArgs() caused a crash in using fromhex() for subclasses. New tests added in bpo-23640 covers this case.

    @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
    interpreter-core (Objects, Python, Grammar, and Parser dirs) performance Performance or resource usage
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants