Skip to content

Speedup float pack / unpack #122534

@ruema

Description

@ruema

Feature or enhancement

Proposal:

The code for packing and unpacking floating point numbers is typically a single memory operation on modern CPUs. However, the current implementation is much more complex.

The functions PyFloat_Pack4, PyFloat_Pack8, PyFloat_Unpack4, and PyFloat_Unpack8 can be refactored to allow compilers to produce more optimal machine code.

For example, using struct.pack(">d", 1.34) is approximately 1.2 times faster.

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

No response

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    interpreter-core(Objects, Python, Grammar, and Parser dirs)performancePerformance or resource usagetype-featureA feature request or enhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions