New submission from Oren Milman: ------------ current state ------------ In six different functions, the following happens: 1. Function x calls _PyLong_New, with var y as the size argument. * Among others, _PyLong_New sets the ob_size of the new int to y (the size argument it received). 2. Function x sets the ob_size of the new int to y, even though y is already the value of ob_size.
The functions in which this happens are: 1. in Objects/longobject.c: - PyLong_FromUnsignedLong - PyLong_FromLongLong - PyLong_FromUnsignedLongLong - PyLong_FromSsize_t - PyLong_FromSize_t 2. in Python/marshal.c: - r_PyLong With regard to relevant changes made in the past, it seems that the redundant assignment was added (in each of these six functions) on the last major rewriting of the function, or when the function was first added, and remained there to this day. The revisions in which the redundant assignments were added: 1. changeset 18114 (https://hg.python.org/cpython/rev/31cd0db0f09f): - PyLong_FromUnsignedLong 2. changeset 38307 (https://hg.python.org/cpython/rev/5a63369056a7): - PyLong_FromLongLong - PyLong_FromUnsignedLongLong 3. changeset 46460 (https://hg.python.org/cpython/rev/b04f2052e812): - PyLong_FromSize_t - PyLong_FromSsize_t 4. changeset 52215 (https://hg.python.org/cpython/rev/bb5de24a343f): - r_PyLong ------------ proposed changes ------------ Remove these six redundant assignments. ------------ diff ------------ The proposed patches diff file is attached. ------------ tests ------------ I built the patched CPython for x86, and played with it a little. Everything seemed to work as usual. In addition, I ran 'python_d.exe -m test -j3' (on my 64-bit Windows 10) with and without the patches, and got quite the same output. The outputs of both runs are attached. ---------- components: Interpreter Core files: CPythonTestOutput.txt messages: 269715 nosy: Oren Milman priority: normal severity: normal status: open title: redundant assignments to ob_size of new ints that _PyLong_New returned type: performance Added file: http://bugs.python.org/file43607/CPythonTestOutput.txt _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue27441> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com