This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author mark.dickinson
Recipients mark.dickinson, niklasf
Date 2017-03-10.18:25:57
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1489170357.61.0.670783613102.issue29782@psf.upfronthosting.co.za>
In-reply-to
Content
Thanks for the idea, and the PR!

To be useful, this would need a bit of tweaking: we can't assume that a digit is always `unsigned long` (in fact, I'd expect that to be rare on 64-bit non-Windows systems, where `unsigned long` typically has 64 bits, and `digit` should be using a 32-bit type), so we'd need to identify and use the most appropriate variant of clz/clzl/clzll somehow.

I think it would also make sense to move the detection of the existence of `__builtin_clz` and friends into the configuration machinery: these builtins aren't just restricted to GCC (clang supports them as well), and that would allow other platforms to provide their own substitutes by modifying `pyport.h`. Ideally, the configuration machinery #defines a HAVE_CLZ variable, and then in longobject.c we do an #ifdef HAVE_CLZ ...

We also need to trade-off the additional complication in the implementation against the benefits: though we do certainly care about the speed, speed at all costs isn't the target here; readability, portability and maintainability of the source counts, too. It'll probably be easier to weigh those factors once there's an implementation that addresses the above points.
History
Date User Action Args
2017-03-10 18:25:57mark.dickinsonsetrecipients: + mark.dickinson, niklasf
2017-03-10 18:25:57mark.dickinsonsetmessageid: <1489170357.61.0.670783613102.issue29782@psf.upfronthosting.co.za>
2017-03-10 18:25:57mark.dickinsonlinkissue29782 messages
2017-03-10 18:25:57mark.dickinsoncreate