2 ms·
I thought the deferred part could be better. For example, one easy win would be to replace the list comprehensions with a generator: there's no point in alloca
by mattkrause 5y ago
I thought the deferred part could be better.
For example, one easy win would be to replace the list comprehensions with a generator: there's no point in allocating that entire list just so that statistics.mean can iterate over it.
At the opposite end, the switch to a Distribution class also enables a huge speedup: keep the sampling machinery for situations where you actually need (Cacuhy?), but while die.expected_value() returns (self.n_sides+1)/2, which is effectively free.