Author Adrian Wielgosik
Recipients Adrian Wielgosik
Date 2016-11-05.19:37:28
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1478374648.81.0.502575461924.issue28621@psf.upfronthosting.co.za>
In-reply-to
Content
The attached patch uses an existing function bits_in_digit() in two other functions:

- in long_bit_length() - it already had identical logic
- in _PyLong_NumBits() - it used a naive, slower way of calculating bit length, so as an added bonus the patch speeds it up a bit. It's visible in float-long comparison microbenchmark:

$ ./old -m timeit "1 == 1.0"
5000000 loops, best of 5: 55 nsec per loop

$ ./new -m timeit "1 == 1.0"
5000000 loops, best of 5: 52.3 nsec per loop

$ ./old -m timeit "12345678 == 12345678.0"
5000000 loops, best of 5: 70.4 nsec per loop

$ ./new -m timeit "12345678 == 12345678.0"
5000000 loops, best of 5: 53.5 nsec per loop
History
Date User Action Args
2016-11-05 19:37:28Adrian Wielgosiksetrecipients: + Adrian Wielgosik
2016-11-05 19:37:28Adrian Wielgosiksetmessageid: <1478374648.81.0.502575461924.issue28621@psf.upfronthosting.co.za>
2016-11-05 19:37:28Adrian Wielgosiklinkissue28621 messages
2016-11-05 19:37:28Adrian Wielgosikcreate