On 10/7/2011 7:13 PM, Terry Reedy wrote: > On 10/7/2011 10:06 AM, Nick Coghlan wrote: >> FWIW, I don't mind whether it's "< 0" or "== -1", so long as there's a >> comparison there to kick my brain out of Python boolean logic mode. > > Is there any speed difference (on common x86/64 processors and > compilers)? I would expect that '< 0' should be optimized to just check > the sign bit and 'if n < 0' to 'load n; jump-non-negative'. >
There are several different ways to express those operators depending on the context. If "n" is worth moving into a register, then "<0" will get to use a "test" and it's fewer instruction bytes than a "cmp", but otherwise, it is no better. So, there is a very special case where "<0" is better, but I think you'd be hard-pressed to measure it against the noise. -- Scott Dial sc...@scottdial.com _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com