python / cpython

The Python programming language
https://www.python.org
Other
63.75k stars 30.54k forks source link

Speedup float pack / unpack #122534

Open ruema opened 4 months ago

ruema commented 4 months ago

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

terryjreedy commented 4 months ago

Why did you close the PR? Unwilling to sign the CLA? Something else? Should this issue be closed?

nineteendo commented 4 months ago

Another PR was created, but it currently only includes the news entry: #122536

ruema commented 4 months ago

the email address was not set correctly in the git commits. So I had to create a new branch. Sorry for that.