~ 1 = -2 ???

Les Schaffer godzilla at netmeg.net
Fri Nov 5 10:42:21 EST 1999


tim said bit-erly:

> Les, if x is always in range(16)

you bet!

class GroupElements:
    elements = range(16)
...


> simply subtract it from 15.  That is,

> def not4bit(x):
>     assert 0 <= x < 16
>     return 15 - x

> It's twice as fast <wink>.

for this particular app, its a little pseudo-group theory applied to
4-bit bit patterns. so  speed don;t matter. but i have some pixel op
stuff coming up, so i am glad i made some dumb mistakes NOW rather
than later!

why i would have even thought python's int's would be unsigned int's
is beyond me....

;-)

les schaffer




More information about the Python-list mailing list