On Sat, Jul 21, 2018 at 1:14 AM, Grant Edwards
<grant.b.edwa...@gmail.com> wrote:
> On 2018-07-20, Dennis Lee Bieber <wlfr...@ix.netcom.com> wrote:
>
>> While I suspect Python isn't micro-optimizing, take into account
>> that most processors do have an "increment"/"decrement" operation --
>> since that is done so much at the low-level. Also, just general
>> integer addition is common, so the hardware may be optimized for
>> doing them fast. Boolean operations may not be as well optimized.
>
> Boolean operations are also very common at the lowest level, and they
> involve far simpler logic than does addition.  I refuse to believe
> there's an extant processor in common use where an ADD is faster than
> an OR unless somebody shows me the processor spec sheet.
>

"Faster than"? I'd agree with you. But "as fast as"? I believe that's
how most modern CPUs already operate. (Well, mostly.) There are
sophisticated methods of daisy-chaining the carry bit that mean the
overall addition can be performed remarkably quickly, and the end
result is a one-clock ADD operation, same as OR. For most data, most
code, and most situations, integer addition is exactly as fast as
integer bit shift.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to