[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: boolean operators
- From: David Given <dg@...>
- Date: Thu, 21 Sep 2006 22:53:34 +0000
Glenn Maynard wrote:
> You don't need bitwise operators to get bitwise operations, though. What's
> wrong, in your case, with having them as functions?
> netmask = math.or(netmask, 0x000000FF)
Functions are slow.
Your example for example, involves two table lookups and a call frame.
The patch I use uses extra opcodes, at a fraction of the overhead;
what's more, this allows the compiler to do constant folding. For example:
netmask = netmask |
...can become a single opcode. (Although I don't know if my patch
actually does this.)
This may seem trivial, but given the way bitfields are commonly used,
you typically want speed.