[issue4680] Queue class should include high-water mark
Roy Smith
report at bugs.python.org
Wed Dec 17 20:49:52 CET 2008
Roy Smith <roy at panix.com> added the comment:
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?
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue4680>
_______________________________________
More information about the Python-bugs-list
mailing list