[issue4680] Queue class should include high-water mark

2008-12-16 Thread Roy Smith

New submission from Roy Smith :

It would be nice if Queue.Queue included a way to access the high-water 
mark, i.e. the largest value which qsize() has ever reached.  This is 
often useful when assessing application performance.

I am assuming this is cheap, i.e. O(1), to provide.

--
components: Library (Lib)
messages: 77955
nosy: roysmith
severity: normal
status: open
title: Queue class should include high-water mark
type: feature request
versions: Python 2.5.3

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue4680] Queue class should include high-water mark

2008-12-16 Thread David W. Lambert

Changes by David W. Lambert :


--
nosy: +LambertDW

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue4680] Queue class should include high-water mark

2008-12-16 Thread Martin v. Löwis

Changes by Martin v. Löwis :


--
versions: +Python 2.7 -Python 2.5.3

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue4680] Queue class should include high-water mark

2008-12-17 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

It is probably easy enough to do so in a custom Queue subclass, and it's
too specialized to put in the standard library IMHO.
I'm closing the bug, another developer can reopen it if he thinks it is
truely useful.

--
nosy: +pitrou
resolution:  -> rejected
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue4680] Queue class should include high-water mark

2008-12-17 Thread Raymond Hettinger

Raymond Hettinger  added the comment:

I concur with Antoine.

--
nosy: +rhettinger

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue4680] Queue class should include high-water mark

2008-12-17 Thread Roy Smith

Roy Smith  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 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com