The way to properly serialize Pickup instance
ababich opened this issue · 0 comments
ababich commented
What is the task:
imagine I need 10 element with weighted probabilities
- I initialized Pickup object with weights like
{a: 80, b: 20}
and got result
list = [a a a b a a a a b a]
- After that I "consumed" 2 first elements:
list = [a b a a a a b a]
And I need to fill the end, i.e. pick 2 more items
- If I init new pickup object with same probabilities I will get different result from what I can have if I will be able to reuse previous (original) object
And these results are worse, especially with low-probability keys
So the easiest way is to serialize and store the initial object but I do not see any straightforward way to do so.
Can you please help?