Message77981
I'm suppose you could implement this in a subclass, but it would be
inefficient. You'd have to over-ride put() and get(), call qsize(),
then delegate to Base.put() and Base.get().
A cleaner solution would be in the C implementation of deque, in
Modules/collectionsmodule.c. There's just a couple of places where
queue->len gets incremented. All that needs to happen is add:
if (queue->len > queue->high_water_mark) {
queue->high_water_mark = queue->len;
}
after each one and then add the appropriate accessor functions in deque
and Queue to expose it to users. The run-time cost is a couple of
machine instructions for each item added to the deque.
If I were to write the code and submit it, would you be willing to
accept it? |
|
Date |
User |
Action |
Args |
2008-12-17 19:49:52 | roysmith | set | recipients:
+ roysmith, rhettinger, pitrou, LambertDW |
2008-12-17 19:49:52 | roysmith | set | messageid: <1229543392.15.0.617798556962.issue4680@psf.upfronthosting.co.za> |
2008-12-17 19:49:51 | roysmith | link | issue4680 messages |
2008-12-17 19:49:50 | roysmith | create | |
|