From: Raymond Hettinger <raymond.hettin...@gmail.com>
> On Jan 25, 2010, at 11:22 AM, Steve Howell
> wrote:
> I
> am interested in creating a patch to make deleting elements
> from the front of Python list work in O(1) time by advancing
> the ob_item pointer.
>
> +1 on doing whatever experiments you feel like
> doing-1 on putting something like this in the
> core
> 1) To many things in the Python world rely on
> the current implementation of lists.  It's not
> worth breaking third-party extensions, tools like psyco,
> work on unladen swallow, and other implementations of Python
> such as PyPy and Jython.

I don't understand how changing the implementation of CPython would impact PyPy 
and Jython, unless you are just referring to the fact that CPython is treated 
as a reference implementation, so its simplicity is a virtue for other ports.  
Am I missing something else?


> 2). The use of lists pervades the language and
> it doesn't make sense to have the language as a whole
> pay a price (in terms of speed and space) for every list
> that gets created.  The corner case isn't worth
> it.

I understand the tradeoff.

> 3).  We already got one.  The
> collections.deque() class was introduced specifically to
> handle inserting and popping from the front of a list
> efficiently.

I understand that deque solves some problems that list does not.  Obviously, it 
allows you to delete elements off the front in O(1) time, but it also has other 
advantages, such as allowing you to rotate elements efficiently.  It's 
designed, I am guessing, for FIFO queues, and it's a perfectly good data 
structure, just not one that is well suited for all use cases.

> 4).  In the comp.lang.python thread on this
> subject, you've gotten nearly zero support for your
> position and have managed to offend many of the
> developers.

Fair enough.  I think the idea is at least worthy of a PEP that puts forward 
the strongest case possible.

Terry Jan Reedy wrote:

'''
I am not opposed to a possible change, just hasty, ill-informed
criticism. If there is not a PEP on this issue, it would be good to have
one that recorded the proposal and the pros and cons, regardless of the
outcome, so there would be something to refer people to. If that had
been already done, it would have shortened this thread considerably.
'''

Do you agree that it is at least worthwhile to write a PEP here?  It could be 
fairly short and quickly rejected, and down the road, if more people get behind 
it, it could always be strengthened and revisited.

There seems to be at least some precedence for PEPs that only pertain to 
internal implementation details, such as this one:

http://www.python.org/dev/peps/pep-0267/

(Raymond, apologies for my double reply...the first one was meant to go to the 
list, not directly to you.)


_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to