[Patches] [ python-Patches-693753 ] fix for bug 639806: default for dict.pop

SourceForge.net noreply@sourceforge.net
Fri, 28 Feb 2003 17:30:10 -0800


Patches item #693753, was opened at 2003-02-26 11:51
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=693753&group_id=5470

Category: Core (C code)
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Michael Stone (mbrierst)
>Assigned to: Guido van Rossum (gvanrossum)
Summary: fix for bug 639806: default for dict.pop

Initial Comment:
This patch adds an optional default value to dict.pop,
so that it parallels dict.get, see discussion in bug
639806.

If no default is given, the old behavior still exists,
so backwards compatibility is no problem.
The new pop must use METH_VARARGS
and PyArg_UnpackTuple, somewhat effecting
efficiency.

If this is considered desirable, I could also
provide the same behavior for list.pop.

----------------------------------------------------------------------

>Comment By: Raymond Hettinger (rhettinger)
Date: 2003-02-28 20:30

Message:
Logged In: YES 
user_id=80475

The patch looks fine.  Assigning to Guido for 
pronouncement.

Guido, the patch adds optional get() like functionality for 
dict.pop().  The nearest parallel is the default argument for 
getattr(obj, attr, [default]).  On the plus side, it makes pop 
easier to use and more flexible.  On the minus side, it adds 
more complexity to the mapping interface and it slows 
down the normal case for d.pop(k).

If it is accepted the poster should add test cases, a NEWS 
item, doc updates, and parallel changes to 
UserDict.UserDict and UserDict.DictMixin.  Then, re-assign 
to me and I'll check it all and apply it.



----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=693753&group_id=5470