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

PEP 757: Rename endian to endianness #3973

Merged
merged 5 commits into from
Sep 18, 2024
Merged

Conversation

vstinner
Copy link
Member

@vstinner vstinner commented Sep 18, 2024

  • Remove the "Optimize small integers" section.
  • Elaborate on PyLong_GetNativeLayout() validity.
  • Mention PyLong_FreeExport() in the specification.

📚 Documentation preview 📚: https://pep-previews--3973.org.readthedocs.build/

* Remove the "Optimize small integers" section.
* Elaborate on PyLong_GetNativeLayout() validity.
* Mention PyLong_FreeExport() in the specification.
@vstinner
Copy link
Member Author

@skirpichev: I don't think that the "Optimize small integers" section is still relevant since we added PyLongExport.value. What do you think?

@vstinner
Copy link
Member Author

Rename endian to endianness

That's a request of @pitrou.

@skirpichev
Copy link
Member

skirpichev commented Sep 18, 2024 via email

@skirpichev
Copy link
Member

skirpichev commented Sep 18, 2024 via email

@skirpichev
Copy link
Member

@vstinner, maybe you can update benchmarks for export? See python/cpython#121339 (comment). With latest changes, something like third one is relevant.

@vstinner
Copy link
Member Author

I think it's still relevant for writing API. The GMPy_PyLong_From_MPZ() has special case with PyLong_FromLong().

Ok, but is it worth it to mention it in the PEP? The gmpy code uses GMP functions for that: mpz_fits_slong_p().

I'm planning to format API sections as sphinx docs from the pr.

I don't understand. Do you want to modify this PR?

@vstinner, maybe you can update benchmarks for export?

I updated benchmarks with results that I got locally.

My benchmark doesn't look very reliable since the reference timings changed as well. But well, it should give an idea of the performance.

@skirpichev
Copy link
Member

skirpichev commented Sep 18, 2024

The gmpy code uses GMP functions for that: mpz_fits_slong_p().

Yes, but the point is to fallback on PyLong_FromLong() to avoid generic code.

Do you want to modify this PR?

No, it's big enough:)

My benchmark doesn't look very reliable since the reference timings changed as well.

I don't expect that there are some recent changes in gmpy2, that might affect timings on this area.

@skirpichev
Copy link
Member

Mark Shannon asked to include also reference code in some form. We can, for example, provide hyperlinks to github.

mpz_set_PyLong:
https://github.com/aleaxit/gmpy/blob/9177648c23f5c507e46b81c1eb7d527c79c96f00/src/gmpy2_convert_gmp.c#L42-L69

GMPy_PyLong_From_MPZ:
https://github.com/aleaxit/gmpy/blob/9177648c23f5c507e46b81c1eb7d527c79c96f00/src/gmpy2_convert_gmp.c#L128-L156

@vstinner
Copy link
Member Author

Yes, but the point is to fallback on PyLong_FromLong() to avoid generic code.

I restored the "small integer" section, but rephrased it only for the import API.

@vstinner vstinner merged commit 9475fa0 into python:main Sep 18, 2024
6 checks passed
@vstinner vstinner deleted the pep757_endianness branch September 18, 2024 12:00
@vstinner
Copy link
Member Author

Mark Shannon asked to include also reference code in some form. We can, for example, provide hyperlinks to github.

I let you create a PR if you want to add that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants