try hyperloglog and find its only good at superbig

master
Bel LaPointe 2023-05-01 07:04:56 -06:00
parent afd982cf6c
commit 0004ca9d83
1 changed files with 23 additions and 0 deletions

23
hyperloglog.py Normal file
View File

@ -0,0 +1,23 @@
import sys
def main(args):
if not args:
args = [str(chr(c)) for c in range(ord('a'), ord('z'))]
bucket = 0
for arg in args:
v = '{:b}'.format(hash(arg)).lstrip('-')
i = 63 - len(v)
for c in v:
if c != '0':
break
i += 1
if i > bucket:
bucket = i
print(f'{i} <= {v} <= {arg}')
print(f'result={2**bucket}')
if __name__ == "__main__":
main(sys.argv[1:])