-
-
Notifications
You must be signed in to change notification settings - Fork 30k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
deque class should include high-water mark #48930
Comments
It would be nice if Queue.Queue included a way to access the high-water I am assuming this is cheap, i.e. O(1), to provide. |
It is probably easy enough to do so in a custom Queue subclass, and it's |
I concur with Antoine. |
I'm suppose you could implement this in a subclass, but it would be A cleaner solution would be in the C implementation of deque, in 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 If I were to write the code and submit it, would you be willing to |
Will think about it for a bit. My initial inclination is against For deques, should the clear() method zero-out the high-water mark? How |
I'm not actually sure what the use case is for clear(). It's easy Popping all the elements off the deque certainly should *not* reset the You do raise a good question about whether all of the standard |
FWIW, here's a trivial Queue subclass with instrumentation: class HighWaterQueue(Queue):
def _init(self, maxsize):
Queue.__init__(self, maxsize)
self.highwater = 0
def _put(self, item):
Queue._put(self, item)
self.highwater = max(self.highwater, self._qsize()) |
And, FWIW, I did figure out a use case for clear(). I create a queue and As I see it, it comes down to this: If you bury this in the C code inside deque(), it's very efficient compared If you feel the efficiency gain doesn't justify the added complexity in the |
There's no need to keep asking -- this report was already rejected ;-) Seriously, the efficiency argument carries no weight with me -- in 15 |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: