Hi I am fairly new to python. I am trying to generate a powerset of all combinations for a list of integers, using the recommended code:
def powerset(iterable):
s = list(iterable)
return chain.from_iterable(combinations(s, r) for r in range(len(s)+1))
My list of integers comes in a numpy array from a pandas dataframe. Each int32 integer costs 48 bytes (not quite sure why so much). Thus, as the list of integers increases, it starts placing significant demands on RAM (e.g. 24 integers ==> at some point the list is about 800 Mb in size)
Is there a way around it? How would one manage the memory efficiently, if say you wanted to generate a powerset of 50 integers or more?
Thank you for any answers / pointers in advance.