[ python-Bugs-950055 ] Is cmdqueue attribute used?
SourceForge.net
noreply at sourceforge.net
Fri May 7 17:50:42 EDT 2004
Bugs item #950055, was opened at 2004-05-07 14:25
Message generated for change (Comment added) made by gvanrossum
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=950055&group_id=5470
Category: Python Library
Group: Python 2.3
Status: Closed
Resolution: None
Priority: 5
Submitted By: Raymond Hettinger (rhettinger)
Assigned to: Guido van Rossum (gvanrossum)
Summary: Is cmdqueue attribute used?
Initial Comment:
In cmd.py, the cmdqueue attribute is set to a list and
checked for pending items but never is filled by any
method nor is it in the documented API.
Is the interface incomplete or is the attribute bogus?
----------------------------------------------------------------------
>Comment By: Guido van Rossum (gvanrossum)
Date: 2004-05-07 17:50
Message:
Logged In: YES
user_id=6380
Well, there is a reason why it took Python 14+ years to grow
a specialized queue/deque datatype. One of Python's premises
is that having a small number of fast general data
structures is better than having many specialized ones, even
if the specialized ones are sometimes faster: msot of the
time you don't care so much about speed, and you just end up
wasting time worrying (or arguing :-) about the right choice
of data structure. Many Python programmers don't know O(n)
from O(1), and shouldn't have to care, because their
problems are never large enough for the difference to matter.
I would suggest that the deque should be used only in
situations where a concern for performance with a large
number of items is realistic, otherwise I fear we risk make
everyone speed freaks, worrying so much about optimizations
that they forget to write correct code first.
If you want examples, put them in the documentation; I'm not
for making small changes to the stdlib all the time to use
new features.
----------------------------------------------------------------------
Comment By: Raymond Hettinger (rhettinger)
Date: 2004-05-07 17:40
Message:
Logged In: YES
user_id=80475
Okay. Just checking.
The idea was to establish habit and example for O(1)
algorithms over O(n) approaches. Queing applications are
what deque's where designed for -- they scale well and
popleft() reads more clearly than .pop(0)
Of course, this attribute only gets accessed once every
million years, so the only real benefit is setting an example.
----------------------------------------------------------------------
Comment By: Guido van Rossum (gvanrossum)
Date: 2004-05-07 17:28
Message:
Logged In: YES
user_id=6380
And what problem would making it a deque solve?
And why shouldn't someone be allowed to remove a protocol
from the list?
Why not leave well enough alone?
----------------------------------------------------------------------
Comment By: Raymond Hettinger (rhettinger)
Date: 2004-05-07 17:07
Message:
Logged In: YES
user_id=80475
It looks like the interface is limited to an append method.
Would it be reasonable to make cmdqueue a deque() object
and replace the pop(0) with a popleft()?
----------------------------------------------------------------------
Comment By: Guido van Rossum (gvanrossum)
Date: 2004-05-07 16:50
Message:
Logged In: YES
user_id=6380
It may not be documented, but it is intended for use by
subclasses, e.g. pdb.py.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=950055&group_id=5470
More information about the Python-bugs-list
mailing list