I need to count the number of trailing and leading zeros in a numpy uint64 variable, so right now I'm doing it like this:
# n > 0
n = np.uint64(100)
s = np.binary_repr(n)
trail_zeros = len(s) - len(s.rstrip('0'))
lead_zeros = 64 - len(s)
Is there a better way of doing this, without using strings? The priority is speed. Thank you!

trail_zeros = 63-lead_zeros-s.rfind('1')seems to be a little faster than your solution, still strings thon = np.uint64(0)?