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

2017-06-15 Thread STINNER Victor
STINNER Victor added the comment: > This request was part of the original bug report, so why open a new issue? Making two C functions public is very different from supporting intmax_t. I expect a change of a few lines, whereas my intmax_t patch modified a lot of code. I wanted to simplify

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

2017-06-15 Thread Devin Jeanpierre
Devin Jeanpierre added the comment: Oh, to be clear on this last point: > Hum, who else needs such function except of you? Right now there is no way to convert an int that might be > 64 bits, into a python long, except really bizarre shenanigans, unless we want to rely on

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

2017-06-15 Thread Devin Jeanpierre
Devin Jeanpierre added the comment: > Making two C functions public is very different from supporting intmax_t. I > expect a change of a few lines, whereas my intmax_t patch modified a lot of > code. I requested either a way to create from intmax_t, or from bytes. We have two existing

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

2017-06-15 Thread Devin Jeanpierre
Devin Jeanpierre added the comment: > Devin, I asked you for a strong rationale to add the feature. I don't see > such rationale, so this issue will be closed again. I guess we have different definitions of "strong rationale". Clearer criteria would help. >> It may be better to make

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

2017-06-15 Thread STINNER Victor
STINNER Victor added the comment: Me: > Write your own C extension to do that. Sorry, I don't know what is the best > way to write such C extension. Devin Jeanpierre: > If everyone who wants to convert intptr_t to a python int has to write their > own function, then why not just include it in

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

2017-06-14 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: It may be better to make _PyLong_FromByteArray() and _PyLong_AsByteArray() public. -- ___ Python tracker ___

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

2017-06-14 Thread Devin Jeanpierre
Devin Jeanpierre added the comment: > Write your own C extension to do that. Sorry, I don't know what is the best > way to write such C extension. If everyone who wants to convert intptr_t to a python int has to write their own function, then why not just include it in the C-API? Having

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

2017-06-14 Thread STINNER Victor
STINNER Victor added the comment: > 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? Write your own C extension to do that. Sorry, I don't know what is the best way to write such C extension. Maybe look at

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

2017-06-14 Thread Devin Jeanpierre
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

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

2017-06-14 Thread STINNER Victor
STINNER Victor added the comment: Serhiy Storchaka: "The patch adds too much code, but there is very little need of new feature (...)" 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

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

2017-04-13 Thread Benjamin Peterson
Changes by Benjamin Peterson : -- pull_requests: +1246 ___ Python tracker ___ ___

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

2017-03-28 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: The patch adds too much code, but there is very little need of new feature. In all cases where PyLong_FromLong() and PyLong_FromLongLong() are used conditionally, PyLong_FromLongLong() can be used unconditionally. PyLong_FromLong() is used only because the

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

2017-03-27 Thread STINNER Victor
Changes by STINNER Victor : -- pull_requests: +760 ___ Python tracker ___ ___

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

2016-11-25 Thread STINNER Victor
STINNER Victor added the comment: I guess that the main question is if all platforms supported by Python do support intmax_t? -- ___ Python tracker ___

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

2016-11-25 Thread STINNER Victor
STINNER Victor added the comment: intmax_t-4.patch is a single combined patch for Mercurial. To see individual changes, see the GitHub pull request: https://github.com/python/cpython/pull/46/commits -- ___ Python tracker

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

2016-11-25 Thread STINNER Victor
STINNER Victor added the comment: New attempt to support C intmax_t type, since Python 3.6 now supports a subset of C99: intmax_t-4.patch. Changes: Add support for C intmax_t type: Add new conversions functions for PyLong: PyLong_FromIntMax() PyLong_FromUIntMax()

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

2016-11-25 Thread STINNER Victor
Changes by STINNER Victor : -- nosy: +benjamin.peterson ___ Python tracker ___ ___

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

2014-10-16 Thread Antoine Pitrou
Antoine Pitrou added the comment: Victor, have you seen https://code.google.com/p/msinttypes/ ? -- nosy: +pitrou ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17870 ___

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

2014-10-16 Thread Antoine Pitrou
Changes by Antoine Pitrou pit...@free.fr: -- stage: needs patch - patch review versions: +Python 3.5 -Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17870 ___

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

2014-10-16 Thread STINNER Victor
STINNER Victor added the comment: Victor, have you seen https://code.google.com/p/msinttypes/ ? Not yet. See also AX_CREATE_STDINT_H: http://bugs.python.org/issue17884#msg188518 http://bugs.python.org/issue17884#msg188527 -- ___ Python tracker

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

2014-10-15 Thread Josh Rosenberg
Changes by Josh Rosenberg shadowranger+pyt...@gmail.com: -- nosy: +josh.r ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17870 ___ ___

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

2014-10-14 Thread Stefan Krah
Changes by Stefan Krah stefan-use...@bytereef.org: -- nosy: -skrah ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17870 ___ ___ Python-bugs-list

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

2013-07-02 Thread Mark Dickinson
Mark Dickinson added the comment: Yes, I apologise; I haven't had time for review. I'll unassign so that someone else can pick this up. It would still be good to have an independent review from someone before this goes in, though. -- assignee: mark.dickinson -

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

2013-07-01 Thread STINNER Victor
STINNER Victor added the comment: Updated patch (version 3), addressing last issues of Mark's review: - add a simple unit test in _testcapi: check that PyLong_AsIntMax_t(INTMAX_INT - 1), PyLong_AsIntMax_t(INTMAX_MAX + 1) and PyLong_AsUintMax_t(UINTMAX_MAX + 1) fail with OverflowError - rely

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

2013-06-05 Thread STINNER Victor
STINNER Victor added the comment: Another place where PyLong_FromIntMax_t() would help, _elementtree.c: id = PyLong_FromSsize_t((Py_uintptr_t) self); selectmodule.c defines PyLong_AsUintptr_t() with: #if (SIZEOF_UINTPTR_T != SIZEOF_VOID_P) # error uintptr_t does not match void *! #elif

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

2013-06-05 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Another place where PyLong_FromIntMax_t() would help, _elementtree.c: id = PyLong_FromSsize_t((Py_uintptr_t) self); I think PyLong_FromVoidPtr() should be used here. -- ___ Python tracker

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

2013-05-16 Thread STINNER Victor
STINNER Victor added the comment: Oh, the sqlite3 module has an interesting function: PyObject * _pysqlite_long_from_int64(sqlite_int64 value) { #ifdef HAVE_LONG_LONG # if SIZEOF_LONG_LONG 8 if (value PY_LLONG_MAX || value PY_LLONG_MIN) { return _PyLong_FromByteArray(value,

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

2013-05-12 Thread Mark Dickinson
Mark Dickinson added the comment: Some comments for the first patch (I haven't really looked at the second): - I would much prefer PyLong_AsIntMax_t not to use nb_int; it should work only for instances of 'int' (just as PyLong_AsSsize_t and PyLong_AsSize_t currently do). - There's a missing

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

2013-05-12 Thread STINNER Victor
STINNER Victor added the comment: Version 2 of my patch: Mark - I would much prefer PyLong_AsIntMax_t not to use nb_int; Mark it should work only for instances of 'int' (just as Mark PyLong_AsSsize_t and PyLong_AsSize_t currently do). I copied code from PyLong_AsLongLong(), but doc from

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

2013-05-08 Thread Mark Dickinson
Mark Dickinson added the comment: I'll take a look. -- assignee: - mark.dickinson ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17870 ___ ___

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

2013-05-07 Thread STINNER Victor
STINNER Victor added the comment: @Mark: any opinion on my patch? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17870 ___ ___ Python-bugs-list

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

2013-04-30 Thread Mark Dickinson
Changes by Mark Dickinson dicki...@gmail.com: -- nosy: +mark.dickinson ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17870 ___ ___

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

2013-04-30 Thread Mark Dickinson
Changes by Mark Dickinson dicki...@gmail.com: -- stage: - needs patch type: - enhancement ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17870 ___

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

2013-04-30 Thread STINNER Victor
STINNER Victor added the comment: It is the same question than yours: is there a platform with an integer type wider than a pointer (intptr_t/void*)? It's x86. sizeof(void*) == 4, sizeof(long long) == 8. Ah yes. So SIZEOF_VOID_P = is not a good test. File position (off_t) size can be 64

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

2013-04-30 Thread STINNER Victor
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

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

2013-04-30 Thread STINNER Victor
STINNER Victor added the comment: Some Google searchs told me that no CPU support 128-bit integer and using 64-bit integer as intmax_t is safe. GCC has a __int128 type, but I didn't find on which platform it is supported, nor if intmax_t is __int128 in this case. Microsoft Visual Studio has

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

2013-04-30 Thread STINNER Victor
STINNER Victor added the comment: Here is a first patch adding the following functions: PyObject* PyLong_FromIntMax_t(intmax_t v); PyObject* PyLong_FromUintMax_t(uintmax_t v); intmax_t PyLong_AsIntMax_t(PyObject *pylong); uintmax_t PyLong_AsUintMax_t(PyObject *pylong); I used

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

2013-04-30 Thread STINNER Victor
STINNER Victor added the comment: See also issue #17884. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17870 ___ ___ Python-bugs-list mailing

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

2013-04-30 Thread STINNER Victor
STINNER Victor added the comment: Another patch to use PyLong_FromIntMax_t(). -- Added file: http://bugs.python.org/file30085/use_intmax_t.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17870

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

2013-04-29 Thread STINNER Victor
Changes by STINNER Victor victor.stin...@gmail.com: -- title: Python does not provide a PyLong_FromIntptr_t() function - Python does not provide PyLong_FromIntMax_t() or PyLong_FromUintMax_t() function ___ Python tracker rep...@bugs.python.org

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

2013-04-29 Thread STINNER Victor
STINNER Victor added the comment: The problem is to support platforms not providing a intmax_t type. I don't know if the following C code would be a good approximation of the maximum integral value (signed/unsigned). #ifdef HAVE_INTMAX_T typedef intmax_tPy_intmax_t; typedef uintmax_t

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

2013-04-29 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: It is the same question than yours: is there a platform with an integer type wider than a pointer (intptr_t/void*)? It's x86. sizeof(void*) == 4, sizeof(long long) == 8. -- nosy: +serhiy.storchaka ___ Python