Message292522
The class collections.Counter should semantically contain only numbers, so it makes sense to define dot product od Counters, something like this:
def __matmul__(self, other):
return sum(self[x] * other[x] for x in self.keys() | other.keys())
I find this useful ocassionaly. |
|
Date |
User |
Action |
Args |
2017-04-28 10:19:20 | Jáchym Barvínek | set | recipients:
+ Jáchym Barvínek |
2017-04-28 10:19:20 | Jáchym Barvínek | set | messageid: <1493374760.56.0.320449301178.issue30196@psf.upfronthosting.co.za> |
2017-04-28 10:19:20 | Jáchym Barvínek | link | issue30196 messages |
2017-04-28 10:19:20 | Jáchym Barvínek | create | |
|