def isNear(self, address):
difference = 0
# a logically anded array ([true, false, ..]) multiplied by an integer is promoted to an int array.
# Which then can be sent to packbits, that here returns an array of 1 element, so now z is an integer
z = np.packbits(np.logical_and(self.address, address)*1)[0]
while z:
difference += 1
z &= z-1 # magic!
return 1 if difference < self.radius else 0
评论列表
文章目录