| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
The way to do it is to move the conditional compilation to C e.g.: python-flint/src/flint/flintlib/types/fmpz_mod_mat_compat.pxd Lines 4 to 14 in b2b71f4 |
Sorry, something went wrong.
Is there anything that can improve this either in CPython or GMP? Or should we just conclude that for python-flint the approach in gh-324 is best? The approach in gh-324 seems simpler and works for all supported CPython versions without needing any conditional compilation. What are gmpy2 or python-gmp going to use? |
Sorry, something went wrong.
Yes, makes sense. I think it should be possible to expose simple wrappers like gmpy2's mpz_set_PyLong(), which will have all needed fallbacks.
I don't think that something can be impoved on CPython side, at least not for "big enough" integers. The PEP 757 API provides raw access to the "array of digits" view for CPython int's. Though, maybe mpz_import/export() could be improved.
Unfortunately, #324 approach can't be translated to C easily for all supported CPython versions. Probably, I'll keep the current solution, but will benchmark also new approach (PyLong_AsNativeBytes/PyLong_FromNativeBytes). |
Sorry, something went wrong.
Without having looked at the code my guess would be that because these functions are quite general they end up being less efficient than PyLong_AsNativeBytes/PyLong_FromNativeBytes when dealing specificially with CPython's 30 bit limb format. |
Sorry, something went wrong.
|
Okay thanks @skirpichev for the benchmarks here. This PR was useful but I think what it proves is that we should go with gh-324 instead. |
Sorry, something went wrong.
Actually perhaps it suggests that we should not use mpz_import/mpz_export but it might still be faster to use PEP 757 with some custom C code that is specialised for the 30 bit limb case. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Closes #159
This lacks implementation for Python < 3.14. Not sure how to do this better, conditional compilation seems to be deprecated by Cython.
To my surprise, #324 approach seems to be better. Here my benchmarks.
Export
Import