Message123759
I've done as Antoine asked and made a pure Python PyCounter class and a C-enhanced Counter class that both use the mixin CounterBase class. I also added to the tests so that both PyCounter and Counter are tested. I left the update_fromsubs() method in Counter for now, but haven't made a Python equivalent function for PyCounter in case the method is rejected.
Also, I realized that my build was still in debug mode so those benchmark weren't quite accurate (Oops). The Counter class is only 4-6x faster for most cases. That's still good, but not quite as good as I'd previously reported.
Lastly, I thought of one more method that could be quite useful. Say that you have a list like [('apples',4),('oranges',5),('apples',8)] where the second element in each tuple indicates how many of them there are. The resultant Counter should have {'apples': 12, 'oranges':5}. We don't really have a good way to count this, but we could add a small method like the following:
def fromitems(self, items):
for key, value in items:
self[key] += value
and I could easily make a C function for it. I think that this simple method could be very useful to some people. What do you all think of this addition? |
|
Date |
User |
Action |
Args |
2010-12-11 00:26:47 | jpeel | set | recipients:
+ jpeel, rhettinger, pitrou, asvetlov, daniel.urban |
2010-12-11 00:26:45 | jpeel | set | messageid: <1292027205.69.0.484206035124.issue10667@psf.upfronthosting.co.za> |
2010-12-11 00:26:43 | jpeel | link | issue10667 messages |
2010-12-11 00:26:43 | jpeel | create | |
|