New submission from Mark Dickinson <dicki...@gmail.com>: Here are various minor portability and standards-compliance fixes, optimizations and cleanups for the trunk version of Objects/longobject.c. Most of these also apply to py3k.
I'll admit to an ulterior motive here: the aim is to extract all the trivial, non-behaviour-changing pieces of the 30-bit longdigit patch (issue 4258), in order to make that patch easier to review. A good few of the changes here are designed to weaken the assumptions about the relative sizes of digit, int and long. Detailed contents of this patch: - make longs smaller by being more careful about tp_basicsize: it's defined as offsetof(PyLongObject, ob_digit) instead of the previous sizeof(PyLongObject) - sizeof(digit). On average, this saves 2 bytes per long on 32-bit platforms and 6 bytes per long on 64-bit platforms. This is similar to the fix that's already in py3k, but more portable since it doesn't make assumptions about the amount of padding between the PyVarObject head and the long digits. - add overflow check in _PyLong_New - replace double cast (double -> long -> digit) in PyLong_FromDouble with a single double -> digit cast. - int -> Py_ssize_t fixes in _PyLong_FromByteArray. - fix bogus overflow check in _PyLong_FromByteArray. - inline muladd1 into mul1 - simplify long_hash (without changing its semantics in any way): there's no need for the masking when rotating x; everything in sight is unsigned and unambiguous. - make PyLong_MASK unsigned (of type digit); this is safer, since it's used in many bitwise operations. - remove wdigit from Include/longintrepr.h; it's no longer used - remove some unnecessary forward declarations - add a few extra casts to silence compiler warnings from gcc -Wextra ---------- assignee: marketdickinson components: Interpreter Core files: trunk_long_cleanup.patch keywords: patch messages: 82095 nosy: marketdickinson priority: normal severity: normal stage: patch review status: open title: longobject.c: minor fixes, cleanups and optimizations type: behavior versions: Python 2.7, Python 3.1 Added file: http://bugs.python.org/file13086/trunk_long_cleanup.patch _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue5260> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com