Message84231
> The general machinery for implementing the built-in int function
> should check any result of type long to see if it fits in an int,
> and convert if so.
Attached patch try to convert long to int, and so it fix the intial
problem:
assert isinstance(int(Decimal(-sys.maxint-1), int).
I used benchmark tools dedicated to test integers:
Unpatched:
pidigit.py: 4612.0 ms
bench_int.py: 2743.5 ms
Patched:
pidigit.py: 4623.8 ms (0.26% slower)
bench_int.py: 2754.5 ms (0.40% slower)
So for intensive integer operations, the overhead is low. Using a more
generic benchmark tool (pybench?), you might not be able to see the
difference ;-)
I'm +0 for this patch because it fixes a very rare case:
1 case on (sys.maxint + 1) × 2
0.00000002% with maxint=2^31 |
|
Date |
User |
Action |
Args |
2009-03-26 23:36:34 | vstinner | set | recipients:
+ vstinner, rhettinger, terry.reedy, mark.dickinson, debedb |
2009-03-26 23:36:33 | vstinner | set | messageid: <1238110593.78.0.524370896287.issue5377@psf.upfronthosting.co.za> |
2009-03-26 23:36:30 | vstinner | link | issue5377 messages |
2009-03-26 23:36:28 | vstinner | create | |
|