[Python-Dev] acceptability of asm in python code?

Damien Morton newsgroups1@bitfurnace.com
Sat, 8 Mar 2003 03:26:13 -0500

In the BINARY_ADD opcode, and in most arithmetic opcodes, there is a line
that checks for overflow that looks like this:

if ((i^a) < 0 && (i^b) < 0) goto slow_add;

I got a small speedup by replacing this with a macro defined thusly:

#if defined(_MSC_VER) and defined(_M_IX86)
#define IF_OVERFLOW_GOTO(X) __asm { jo X };
#define IF_OVERFLOW_GOTO(X) if ((i^a) < 0 && (i^b) < 0) goto X;

Would this case be an acceptable use of snippets of inline assembler?