> -----Original Message----- > From: Tim Peters [mailto:tim.one@comcast.net] > Sent: Saturday, 8 March 2003 22:42 > To: Damien Morton > Cc: python-dev@python.org > Subject: RE: [Python-Dev] acceptability of asm in python code? > > > [Damien Morton] > > In the BINARY_ADD opcode, and in most arithmetic opcodes, > > Aren't add and subtract the whole story here? ADD, SUBTRACT and INPLACE variants, yes. Potentially also MULTIPLY. > > 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) > > "and" isn't C, so I assume you were very lucky <wink>. I had been using _MSC_VER, but decided to be a bit more specific for my post. Youre right, of course, the define I posted would not have worked. > > #define IF_OVERFLOW_GOTO(X) __asm { jo X }; > > #else > > #define IF_OVERFLOW_GOTO(X) if ((i^a) < 0 && (i^b) < 0) > goto X; #endif > > > > Would this case be an acceptable use of snippets of inline > assembler? > > If you had said "a huge speedup, on all programs", on the > weak end of maybe. "Small speedup" isn't worth the obscurity. > Note that Python contains no assembler now. Its arguable which is more obscure, the x86 assembly instruction "jo" (jump if overflow), or the xor trickery in C. <wink> I take your point, though, about there being no assembly in python now.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4