[issue17870] Python does not provide PyLong_FromIntMax_t() or PyLong_FromUintMax_t() function
STINNER Victor
report at bugs.python.org
Tue Apr 30 12:38:19 CEST 2013
STINNER Victor added the comment:
> Or maybe even better would be PyLong_FromBytes(&myinteger, sizeof(myinteger)) ?
There is a private function:
obj = _PyLong_FromByteArray((const unsigned char*)&myinteger, sizeof(myinteger), PY_LITTLE_ENDIAN, is_signed);
Where PY_LITTLE_ENDIAN is 1 on little-endian platform, and is_signed should be 0 or 1.
This function is inefficient (slow). It would be better to have a functions for intmax_t and uintmax_t types. Such functions would be enough to support other "recent" C types: intptr_t, uintptr_t, ptrdiff_t, etc. We may also add support for these types in PyArg_Parse* (ex: with "j" and "J" types, intmax_t and uintmax_t).
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue17870>
_______________________________________
More information about the Python-bugs-list
mailing list