Content-Length: 240031 | pFad | http://github.com/lh00000000/tally-py

93 GitHub - lh00000000/tally-py: an always-sorted Counter-like data structure with constant time updates and top-k queries
Skip to content

an always-sorted Counter-like data structure with constant time updates and top-k queries

Notifications You must be signed in to change notification settings

lh00000000/tally-py

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Example

from tally import Tally
from more_itertools import repeatfunc, first
from itertools import islice
import silly

t = Tally()


def print_results(t):
    for i, namevotes in enumerate(islice(t.descending(), 0, 3)):
        name, votes = namevotes
        print("#{} is {} with {} votes. ".format(i + 1, name, votes), end='\t')
    print()

an_infinite_stream_of_random_names = repeatfunc(silly.firstname)
for num in an_infinite_stream_of_random_names:
    t.tally(num)
    print_results(t)

why?

  • for streams where you need to keep track of the top-k
  • for a lfu cache-like things
  • inner torment
  • realtime wordclouds

About

an always-sorted Counter-like data structure with constant time updates and top-k queries

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages









ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/lh00000000/tally-py

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy