I feel like, a better implementation of Clumper would have been the following-
class Clumper:
def __init__(self, blob):
self.blob = blob
# keep function cannot be called without any arguments, atleast 1 would be needed
def keep(self, func, *funcs):
return Clumper([d for d in self.blob if all(func(d) for func in (func, *funcs))])
As the list of functions will be relatively small, we only need to filter the blob once checking if the data satisfies all the functions
I feel like, a better implementation of Clumper would have been the following-
As the list of functions will be relatively small, we only need to filter the
blob
once checking if the data satisfies all the functions