mirror of
https://github.com/python/cpython.git
synced 2025-11-25 04:34:37 +00:00
Merged revisions 64089,64098,64100-64102,64113,64115-64116,64118,64120,64132,64342 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r64089 | armin.ronacher | 2008-06-10 22:37:02 +0200 (mar., 10 juin 2008) | 3 lines Fix a formatting error in the ast documentation. ........ r64098 | raymond.hettinger | 2008-06-11 02:25:29 +0200 (mer., 11 juin 2008) | 6 lines Mini-PEP: Simplifying numbers.py * Convert binary methods in Integral to mixin methods * Remove three-arg __pow__ as a required method * Make __int__ the root method instead of __long__. ........ r64100 | raymond.hettinger | 2008-06-11 02:28:51 +0200 (mer., 11 juin 2008) | 1 line Update numbers doc for the Integral simplification. ........ r64101 | raymond.hettinger | 2008-06-11 02:44:47 +0200 (mer., 11 juin 2008) | 3 lines Handle the case with zero arguments. ........ r64102 | benjamin.peterson | 2008-06-11 03:31:28 +0200 (mer., 11 juin 2008) | 4 lines convert test_struct to a unittest thanks to Giampaolo Rodola I had to disable one test because it was functioning incorrectly, see #1530559 I also removed the debugging prints ........ r64113 | thomas.heller | 2008-06-11 09:10:43 +0200 (mer., 11 juin 2008) | 2 lines Fix markup. Document the new 'offset' parameter for the 'ctypes.byref' function. ........ r64115 | raymond.hettinger | 2008-06-11 12:30:54 +0200 (mer., 11 juin 2008) | 1 line Multi-arg form for set.difference() and set.difference_update(). ........ r64116 | raymond.hettinger | 2008-06-11 14:06:49 +0200 (mer., 11 juin 2008) | 1 line Issue 3051: Let heapq work with either __lt__ or __le__. ........ r64118 | raymond.hettinger | 2008-06-11 14:39:09 +0200 (mer., 11 juin 2008) | 1 line Optimize previous checkin for heapq. ........ r64120 | raymond.hettinger | 2008-06-11 15:14:50 +0200 (mer., 11 juin 2008) | 1 line Add test for heapq using both __lt__ and __le__. ........ r64132 | gregory.p.smith | 2008-06-11 20:00:52 +0200 (mer., 11 juin 2008) | 3 lines Correct an incorrect comment about our #include of stddef.h. (see Doug Evans' comment on python-dev 2008-06-10) ........ r64342 | guido.van.rossum | 2008-06-17 19:38:02 +0200 (mar., 17 juin 2008) | 3 lines Roll back Raymond's -r64098 while we think of something better. (See issue 3056 -- we're close to a resolution but need unittests.) ........
This commit is contained in:
parent
36817a984c
commit
fdfe62d887
10 changed files with 616 additions and 647 deletions
|
|
@ -1304,6 +1304,9 @@ set_intersection_multi(PySetObject *so, PyObject *args)
|
|||
Py_ssize_t i;
|
||||
PyObject *result = (PyObject *)so;
|
||||
|
||||
if (PyTuple_GET_SIZE(args) == 0)
|
||||
return set_copy(so);
|
||||
|
||||
Py_INCREF(so);
|
||||
for (i=0 ; i<PyTuple_GET_SIZE(args) ; i++) {
|
||||
PyObject *other = PyTuple_GET_ITEM(args, i);
|
||||
|
|
@ -1484,11 +1487,16 @@ set_difference_update_internal(PySetObject *so, PyObject *other)
|
|||
}
|
||||
|
||||
static PyObject *
|
||||
set_difference_update(PySetObject *so, PyObject *other)
|
||||
set_difference_update(PySetObject *so, PyObject *args)
|
||||
{
|
||||
if (set_difference_update_internal(so, other) != -1)
|
||||
Py_RETURN_NONE;
|
||||
return NULL;
|
||||
Py_ssize_t i;
|
||||
|
||||
for (i=0 ; i<PyTuple_GET_SIZE(args) ; i++) {
|
||||
PyObject *other = PyTuple_GET_ITEM(args, i);
|
||||
if (set_difference_update_internal(so, other) == -1)
|
||||
return NULL;
|
||||
}
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(difference_update_doc,
|
||||
|
|
@ -1546,10 +1554,34 @@ set_difference(PySetObject *so, PyObject *other)
|
|||
return result;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
set_difference_multi(PySetObject *so, PyObject *args)
|
||||
{
|
||||
Py_ssize_t i;
|
||||
PyObject *result, *other;
|
||||
|
||||
if (PyTuple_GET_SIZE(args) == 0)
|
||||
return set_copy(so);
|
||||
|
||||
other = PyTuple_GET_ITEM(args, 0);
|
||||
result = set_difference(so, other);
|
||||
if (result == NULL)
|
||||
return NULL;
|
||||
|
||||
for (i=1 ; i<PyTuple_GET_SIZE(args) ; i++) {
|
||||
other = PyTuple_GET_ITEM(args, i);
|
||||
if (set_difference_update_internal((PySetObject *)result, other) == -1) {
|
||||
Py_DECREF(result);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(difference_doc,
|
||||
"Return the difference of two sets as a new set.\n\
|
||||
"Return the difference of two or more sets as a new set.\n\
|
||||
\n\
|
||||
(i.e. all elements that are in this set but not the other.)");
|
||||
(i.e. all elements that are in this set but not the others.)");
|
||||
static PyObject *
|
||||
set_sub(PySetObject *so, PyObject *other)
|
||||
{
|
||||
|
|
@ -1563,16 +1595,12 @@ set_sub(PySetObject *so, PyObject *other)
|
|||
static PyObject *
|
||||
set_isub(PySetObject *so, PyObject *other)
|
||||
{
|
||||
PyObject *result;
|
||||
|
||||
if (!PyAnySet_Check(other)) {
|
||||
Py_INCREF(Py_NotImplemented);
|
||||
return Py_NotImplemented;
|
||||
}
|
||||
result = set_difference_update(so, other);
|
||||
if (result == NULL)
|
||||
if (set_difference_update_internal(so, other) == -1)
|
||||
return NULL;
|
||||
Py_DECREF(result);
|
||||
Py_INCREF(so);
|
||||
return (PyObject *)so;
|
||||
}
|
||||
|
|
@ -1963,9 +1991,9 @@ static PyMethodDef set_methods[] = {
|
|||
copy_doc},
|
||||
{"discard", (PyCFunction)set_discard, METH_O,
|
||||
discard_doc},
|
||||
{"difference", (PyCFunction)set_difference, METH_O,
|
||||
{"difference", (PyCFunction)set_difference_multi, METH_VARARGS,
|
||||
difference_doc},
|
||||
{"difference_update", (PyCFunction)set_difference_update, METH_O,
|
||||
{"difference_update", (PyCFunction)set_difference_update, METH_VARARGS,
|
||||
difference_update_doc},
|
||||
{"intersection",(PyCFunction)set_intersection_multi, METH_VARARGS,
|
||||
intersection_doc},
|
||||
|
|
@ -2087,7 +2115,7 @@ static PyMethodDef frozenset_methods[] = {
|
|||
contains_doc},
|
||||
{"copy", (PyCFunction)frozenset_copy, METH_NOARGS,
|
||||
copy_doc},
|
||||
{"difference", (PyCFunction)set_difference, METH_O,
|
||||
{"difference", (PyCFunction)set_difference_multi, METH_VARARGS,
|
||||
difference_doc},
|
||||
{"intersection",(PyCFunction)set_intersection_multi, METH_VARARGS,
|
||||
intersection_doc},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue