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 vstinner
Recipients debedb, mark.dickinson, rhettinger, terry.reedy, vstinner
Date 2009-03-26.23:36:27
SpamBayes Score 1.1229906e-12
Marked as misclassified No
Message-id <1238110593.78.0.524370896287.issue5377@psf.upfronthosting.co.za>
In-reply-to
Content
> 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
History
Date User Action Args
2009-03-26 23:36:34vstinnersetrecipients: + vstinner, rhettinger, terry.reedy, mark.dickinson, debedb
2009-03-26 23:36:33vstinnersetmessageid: <1238110593.78.0.524370896287.issue5377@psf.upfronthosting.co.za>
2009-03-26 23:36:30vstinnerlinkissue5377 messages
2009-03-26 23:36:28vstinnercreate