Oren Milman added the comment: Ah, that's a cool alternative to divide and ceil. I would change my patch accordingly.
And would write the patch also for _PyLong_AsUnsignedLongLongMask, and work on some micro-benchmarking for it and _PyLong_AsUnsignedLongMask. Indeed _testcapimodule.c is not really related. Should I open another issue for that only? (I am often worried about opening many small issues.. Please let me know if I shouldn't be.) Now that you mention it, similar 'while (--i >= 0)' can be found in some other functions: 1. PyLong_AsLongAndOverflow 2. PyLong_AsSsize_t 3. PyLong_AsUnsignedLong 4. PyLong_AsSize_t 5. PyLong_AsLongLongAndOverflow I suspect we could optimize these 5 by first determining whether the Python int has too many bits, instead of shifting and checking for an overflow on each iteration. I would definitely give it a try when I am done with _PyLong_AsUnsignedLongLongMask and _PyLong_AsUnsignedLongMask :) ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue27298> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com