Kaydet (Commit) 0f1451c8 authored tarafından Raymond Hettinger's avatar Raymond Hettinger

Issue 23744: Minor speed-up for deque.__bool__().

üst 929a14a8
......@@ -1249,6 +1249,12 @@ deque_sizeof(dequeobject *deque, void *unused)
PyDoc_STRVAR(sizeof_doc,
"D.__sizeof__() -- size of D in memory, in bytes");
static int
deque_bool(dequeobject *deque)
{
return Py_SIZE(deque) != 0;
}
static PyObject *
deque_get_maxlen(dequeobject *deque)
{
......@@ -1276,6 +1282,23 @@ static PySequenceMethods deque_as_sequence = {
0, /* sq_inplace_repeat */
};
static PyNumberMethods deque_as_number = {
0, /* nb_add */
0, /* nb_subtract */
0, /* nb_multiply */
0, /* nb_remainder */
0, /* nb_divmod */
0, /* nb_power */
0, /* nb_negative */
0, /* nb_positive */
0, /* nb_absolute */
(inquiry)deque_bool, /* nb_bool */
0, /* nb_invert */
0, /* nb_lshift */
0, /* nb_rshift */
};
/* deque object ********************************************************/
static PyObject *deque_iter(dequeobject *deque);
......@@ -1340,7 +1363,7 @@ static PyTypeObject deque_type = {
0, /* tp_setattr */
0, /* tp_reserved */
deque_repr, /* tp_repr */
0, /* tp_as_number */
&deque_as_number, /* tp_as_number */
&deque_as_sequence, /* tp_as_sequence */
0, /* tp_as_mapping */
PyObject_HashNotImplemented, /* tp_hash */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment