[issue17870] Python does not provide PyLong_FromIntMax_t() or PyLong_FromUintMax_t() function

Devin Jeanpierre report at bugs.python.org
Wed Jun 14 17:48:51 EDT 2017


Devin Jeanpierre added the comment:

> I wrote my first patch in 2013, but I still fail to find a very good example where intmax_t would be an obvious choice. So I have to agree and I will now close the issue.

Hold on, nobody ever answered the question in the OP. How would you convert an intptr_t (e.g. Rust's int type) to a Python int?

You can't use FromVoidPtr because of signedness. You can use FromLongLong, but that's implementation-defined.

If what we should be using is FromLongLong for all "really big ints", why not just rename FromLongLong to FromIntMax and call it a day?



There is no standard relationship between long long and most other int types -- all we know is that it's at least 64 bits, but an int type can perfectly reasonably be e.g. 80 bits or 128 bits or similar. I think it *is* a worhtwhile goal to allow programmers to write C code that has as little implementation-defined or undefined behavior as possible.


If that isn't considered a worthwhile goal, maybe we should reconsider using such a dangerous and pointy language as C. :)

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue17870>
_______________________________________


More information about the Python-bugs-list mailing list