assembler optimized integer overflow detection
jepler at inetnebr.com
Mon Aug 23 14:11:08 CEST 1999
On Mon, 23 Aug 1999 11:28:06 +0200, Felix von Delius
<Delius at ebox.de> wrote:
>I wondered how Python detects integer overflows and searched the
>corresponding code snippets in Python's source (Objects/intobject.c).
>Because ANSI-C can't detect int overflow errors, there are very strange
>workarounds for all the basic arithmetic.
>I asked myself if it will be a big performance boost when someone will
>re-code this routines in assembler, because an overflow can be detected very
>simply by checking a processor-flag after performing the operation. Has
>someone done this already? What speedup-factor would an optimization of this
>kind have to the average Python code? Is it worth the work? (Let's say for
>Linux/i386 machines). I'm not an Intel-assembly guy (only M68K experience),
>but I think this wouldn't be too much efford for an Intel hacker, is it?
How big does this code show up in profiling? How poor is the produced code
on your target platform?
My guess is that this isn't a big item in the profile, but I could be
wrong. If it's only, say, 5% and you speed it up by a factor of 5, then
you would gain an overall 4%, not too much. And I don't know that it is
even 5% on the programs I tend to run.
So in the absence of knowledge that this is a significant consumer of CPU
time, and in the absence of knowledge that there's a way to write the C
better, I'd say there's probably no reason to introduce non-portable
assembly code into Python.
\/ http://incolor.inetnebr.com/jepler/ Jeff Epler jepler at inetnebr.com
Better to light one candle than to curse the darkness.
-- motto of the Christopher Society
More information about the Python-list