Back to index

python3.2  3.2.2
Classes | Defines | Typedefs | Functions | Variables
_collectionsmodule.c File Reference
#include "Python.h"
#include "structmember.h"

Go to the source code of this file.

Classes

struct  BLOCK
struct  dequeobject
struct  dequeiterobject
struct  defdictobject

Defines

#define BLOCKLEN   62
#define CENTER   ((BLOCKLEN - 1) / 2)
#define MAXFREEBLOCKS   10
#define TRIM(d, popfunction)
#define DEFERRED_ADDRESS(ADDR)   0

Typedefs

typedef struct BLOCK block

Functions

static blocknewblock (block *leftlink, block *rightlink, Py_ssize_t len)
static void freeblock (block *b)
static PyObjectdeque_new (PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObjectdeque_pop (dequeobject *deque, PyObject *unused)
 PyDoc_STRVAR (pop_doc,"Remove and return the rightmost element.")
static PyObjectdeque_popleft (dequeobject *deque, PyObject *unused)
 PyDoc_STRVAR (popleft_doc,"Remove and return the leftmost element.")
static PyObjectdeque_append (dequeobject *deque, PyObject *item)
 PyDoc_STRVAR (append_doc,"Add an element to the right side of the deque.")
static PyObjectdeque_appendleft (dequeobject *deque, PyObject *item)
 PyDoc_STRVAR (appendleft_doc,"Add an element to the left side of the deque.")
static PyObjectconsume_iterator (PyObject *it)
static PyObjectdeque_extend (dequeobject *deque, PyObject *iterable)
 PyDoc_STRVAR (extend_doc,"Extend the right side of the deque with elements from the iterable")
static PyObjectdeque_extendleft (dequeobject *deque, PyObject *iterable)
 PyDoc_STRVAR (extendleft_doc,"Extend the left side of the deque with elements from the iterable")
static PyObjectdeque_inplace_concat (dequeobject *deque, PyObject *other)
static int _deque_rotate (dequeobject *deque, Py_ssize_t n)
static PyObjectdeque_rotate (dequeobject *deque, PyObject *args)
 PyDoc_STRVAR (rotate_doc,"Rotate the deque n steps to the right (default n=1). If n is negative, rotates left.")
static PyObjectdeque_reverse (dequeobject *deque, PyObject *unused)
 PyDoc_STRVAR (reverse_doc,"D.reverse() -- reverse *IN PLACE*")
static PyObjectdeque_count (dequeobject *deque, PyObject *v)
 PyDoc_STRVAR (count_doc,"D.count(value) -> integer -- return number of occurrences of value")
static Py_ssize_t deque_len (dequeobject *deque)
static PyObjectdeque_remove (dequeobject *deque, PyObject *value)
 PyDoc_STRVAR (remove_doc,"D.remove(value) -- remove first occurrence of value.")
static int deque_clear (dequeobject *deque)
static PyObjectdeque_item (dequeobject *deque, Py_ssize_t i)
static int deque_del_item (dequeobject *deque, Py_ssize_t i)
static int deque_ass_item (dequeobject *deque, Py_ssize_t i, PyObject *v)
static PyObjectdeque_clearmethod (dequeobject *deque)
 PyDoc_STRVAR (clear_doc,"Remove all elements from the deque.")
static void deque_dealloc (dequeobject *deque)
static int deque_traverse (dequeobject *deque, visitproc visit, void *arg)
static PyObjectdeque_copy (PyObject *deque)
 PyDoc_STRVAR (copy_doc,"Return a shallow copy of a deque.")
static PyObjectdeque_reduce (dequeobject *deque)
 PyDoc_STRVAR (reduce_doc,"Return state information for pickling.")
static PyObjectdeque_repr (PyObject *deque)
static PyObjectdeque_richcompare (PyObject *v, PyObject *w, int op)
static int deque_init (dequeobject *deque, PyObject *args, PyObject *kwdargs)
static PyObjectdeque_get_maxlen (dequeobject *deque)
static PyObjectdeque_iter (dequeobject *deque)
static PyObjectdeque_reviter (dequeobject *deque)
 PyDoc_STRVAR (reversed_doc,"D.__reversed__() -- return a reverse iterator over the deque")
 PyDoc_STRVAR (deque_doc,"deque(iterable[, maxlen]) --> deque object\n\ \n\ Build an ordered collection with optimized access from its endpoints.")
static int dequeiter_traverse (dequeiterobject *dio, visitproc visit, void *arg)
static void dequeiter_dealloc (dequeiterobject *dio)
static PyObjectdequeiter_next (dequeiterobject *it)
static PyObjectdequeiter_len (dequeiterobject *it)
 PyDoc_STRVAR (length_hint_doc,"Private method returning an estimate of len(list(it)).")
static PyObjectdequereviter_next (dequeiterobject *it)
 PyDoc_STRVAR (defdict_missing_doc,"__missing__(key) # Called by __getitem__ for missing key; pseudo-code:\n\ if self.default_factory is None: raise KeyError((key,))\n\ self[key] = value = self.default_factory()\n\ return value\n\ ")
static PyObjectdefdict_missing (defdictobject *dd, PyObject *key)
 PyDoc_STRVAR (defdict_copy_doc,"D.copy() -> a shallow copy of D.")
static PyObjectdefdict_copy (defdictobject *dd)
static PyObjectdefdict_reduce (defdictobject *dd)
static void defdict_dealloc (defdictobject *dd)
static PyObjectdefdict_repr (defdictobject *dd)
static int defdict_traverse (PyObject *self, visitproc visit, void *arg)
static int defdict_tp_clear (defdictobject *dd)
static int defdict_init (PyObject *self, PyObject *args, PyObject *kwds)
 PyDoc_STRVAR (defdict_doc,"defaultdict(default_factory) --> dict with default factory\n\ \n\ The default factory is called without arguments to produce\n\ a new value when a key is not present, in __getitem__ only.\n\ A defaultdict compares equal to a dict with the same items.\n\ ")
 PyDoc_STRVAR (_count_elements_doc,"_count_elements(mapping, iterable) -> None\n\ \n\ Count elements in the iterable, updating the mappping")
static PyObject_count_elements (PyObject *self, PyObject *args)
 PyDoc_STRVAR (module_doc,"High performance data structures.\n\ - deque: ordered collection accessible from endpoints only\n\ - defaultdict: dict subclass with a default value factory\n\ ")
PyMODINIT_FUNC PyInit__collections (void)

Variables

static Py_ssize_t numfreeblocks = 0
static blockfreeblocks [MAXFREEBLOCKS]
static PyTypeObject deque_type
static PyGetSetDef deque_getset []
static PySequenceMethods deque_as_sequence
static PyMethodDef deque_methods []
static PyTypeObject dequeiter_type
static PyMethodDef dequeiter_methods []
static PyTypeObject dequereviter_type
static PyTypeObject defdict_type
static PyMethodDef defdict_methods []
static PyMemberDef defdict_members []
static struct PyMethodDef []
static struct PyModuleDef

Class Documentation

struct BLOCK

Definition at line 48 of file _collectionsmodule.c.

Collaboration diagram for BLOCK:
Class Members
PyObject * data
struct BLOCK * leftlink
struct BLOCK * rightlink
struct dequeobject

Definition at line 99 of file _collectionsmodule.c.

Collaboration diagram for dequeobject:
Class Members
PyObject_HEAD block * leftblock
Py_ssize_t leftindex
Py_ssize_t len
Py_ssize_t maxlen
block * rightblock
Py_ssize_t rightindex
long state
PyObject * weakreflist
struct dequeiterobject

Definition at line 1053 of file _collectionsmodule.c.

Collaboration diagram for dequeiterobject:
Class Members
block * b
Py_ssize_t counter
dequeobject * deque
PyObject_HEAD Py_ssize_t index
long state
struct defdictobject

Definition at line 1255 of file _collectionsmodule.c.

Collaboration diagram for defdictobject:
Class Members
PyObject * default_factory
PyDictObject dict

Define Documentation

#define BLOCKLEN   62

Definition at line 16 of file _collectionsmodule.c.

#define CENTER   ((BLOCKLEN - 1) / 2)

Definition at line 17 of file _collectionsmodule.c.

#define DEFERRED_ADDRESS (   ADDR)    0

Definition at line 1478 of file _collectionsmodule.c.

#define MAXFREEBLOCKS   10

Definition at line 54 of file _collectionsmodule.c.

#define TRIM (   d,
  popfunction 
)
Value:
if (d->maxlen != -1 && d->len > d->maxlen) {                \
        PyObject *rv = popfunction(d, NULL);                \
        assert(rv != NULL  &&  d->len <= d->maxlen);        \
        Py_DECREF(rv);                                      \
    }

Definition at line 120 of file _collectionsmodule.c.


Typedef Documentation

typedef struct BLOCK block

Function Documentation

static PyObject* _count_elements ( PyObject self,
PyObject args 
) [static]

Definition at line 1532 of file _collectionsmodule.c.

{
    PyObject *it, *iterable, *mapping, *oldval;
    PyObject *newval = NULL;
    PyObject *key = NULL;
    PyObject *one = NULL;

    if (!PyArg_UnpackTuple(args, "_count_elements", 2, 2, &mapping, &iterable))
        return NULL;

    it = PyObject_GetIter(iterable);
    if (it == NULL)
        return NULL;

    one = PyLong_FromLong(1);
    if (one == NULL) {
        Py_DECREF(it);
        return NULL;
    }

    if (PyDict_CheckExact(mapping)) {
        while (1) {
            key = PyIter_Next(it);
            if (key == NULL) {
                if (PyErr_Occurred() && PyErr_ExceptionMatches(PyExc_StopIteration))
                    PyErr_Clear();
                else
                    break;
            }
            oldval = PyDict_GetItem(mapping, key);
            if (oldval == NULL) {
                if (PyDict_SetItem(mapping, key, one) == -1)
                    break;
            } else {
                newval = PyNumber_Add(oldval, one);
                if (newval == NULL)
                    break;
                if (PyDict_SetItem(mapping, key, newval) == -1)
                    break;
                Py_CLEAR(newval);
            }
            Py_DECREF(key);
        }
    } else {
        while (1) {
            key = PyIter_Next(it);
            if (key == NULL) {
                if (PyErr_Occurred() && PyErr_ExceptionMatches(PyExc_StopIteration))
                    PyErr_Clear();
                else
                    break;
            }
            oldval = PyObject_GetItem(mapping, key);
            if (oldval == NULL) {
                if (!PyErr_Occurred() || !PyErr_ExceptionMatches(PyExc_KeyError))
                    break;
                PyErr_Clear();
                Py_INCREF(one);
                newval = one;
            } else {
                newval = PyNumber_Add(oldval, one);
                Py_DECREF(oldval);
                if (newval == NULL)
                    break;
            }
            if (PyObject_SetItem(mapping, key, newval) == -1)
                break;
            Py_CLEAR(newval);
            Py_DECREF(key);
        }
    }

    Py_DECREF(it);
    Py_XDECREF(key);
    Py_XDECREF(newval);
    Py_DECREF(one);
    if (PyErr_Occurred())
        return NULL;
    Py_RETURN_NONE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int _deque_rotate ( dequeobject deque,
Py_ssize_t  n 
) [static]

Definition at line 414 of file _collectionsmodule.c.

{
    Py_ssize_t i, len=deque->len, halflen=(len+1)>>1;
    PyObject *item, *rv;

    if (len == 0)
        return 0;
    if (n > halflen || n < -halflen) {
        n %= len;
        if (n > halflen)
            n -= len;
        else if (n < -halflen)
            n += len;
    }

    for (i=0 ; i<n ; i++) {
        item = deque_pop(deque, NULL);
        assert (item != NULL);
        rv = deque_appendleft(deque, item);
        Py_DECREF(item);
        if (rv == NULL)
            return -1;
        Py_DECREF(rv);
    }
    for (i=0 ; i>n ; i--) {
        item = deque_popleft(deque, NULL);
        assert (item != NULL);
        rv = deque_append(deque, item);
        Py_DECREF(item);
        if (rv == NULL)
            return -1;
        Py_DECREF(rv);
    }
    return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static PyObject* consume_iterator ( PyObject it) [static]

Definition at line 283 of file _collectionsmodule.c.

{
    PyObject *item;

    while ((item = PyIter_Next(it)) != NULL) {
        Py_DECREF(item);
    }
    Py_DECREF(it);
    if (PyErr_Occurred())
        return NULL;
    Py_RETURN_NONE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static PyObject* defdict_copy ( defdictobject dd) [static]

Definition at line 1296 of file _collectionsmodule.c.

{
    /* This calls the object's class.  That only works for subclasses
       whose class constructor has the same signature.  Subclasses that
       define a different constructor signature must override copy().
    */

    if (dd->default_factory == NULL)
        return PyObject_CallFunctionObjArgs((PyObject*)Py_TYPE(dd), Py_None, dd, NULL);
    return PyObject_CallFunctionObjArgs((PyObject*)Py_TYPE(dd),
                                        dd->default_factory, dd, NULL);
}

Here is the call graph for this function:

static void defdict_dealloc ( defdictobject dd) [static]

Definition at line 1383 of file _collectionsmodule.c.

static int defdict_init ( PyObject self,
PyObject args,
PyObject kwds 
) [static]

Definition at line 1438 of file _collectionsmodule.c.

{
    defdictobject *dd = (defdictobject *)self;
    PyObject *olddefault = dd->default_factory;
    PyObject *newdefault = NULL;
    PyObject *newargs;
    int result;
    if (args == NULL || !PyTuple_Check(args))
        newargs = PyTuple_New(0);
    else {
        Py_ssize_t n = PyTuple_GET_SIZE(args);
        if (n > 0) {
            newdefault = PyTuple_GET_ITEM(args, 0);
            if (!PyCallable_Check(newdefault) && newdefault != Py_None) {
                PyErr_SetString(PyExc_TypeError,
                    "first argument must be callable");
                return -1;
            }
        }
        newargs = PySequence_GetSlice(args, 1, n);
    }
    if (newargs == NULL)
        return -1;
    Py_XINCREF(newdefault);
    dd->default_factory = newdefault;
    result = PyDict_Type.tp_init(self, newargs, kwds);
    Py_DECREF(newargs);
    Py_XDECREF(olddefault);
    return result;
}

Here is the call graph for this function:

static PyObject* defdict_missing ( defdictobject dd,
PyObject key 
) [static]

Definition at line 1270 of file _collectionsmodule.c.

{
    PyObject *factory = dd->default_factory;
    PyObject *value;
    if (factory == NULL || factory == Py_None) {
        /* XXX Call dict.__missing__(key) */
        PyObject *tup;
        tup = PyTuple_Pack(1, key);
        if (!tup) return NULL;
        PyErr_SetObject(PyExc_KeyError, tup);
        Py_DECREF(tup);
        return NULL;
    }
    value = PyEval_CallObject(factory, NULL);
    if (value == NULL)
        return value;
    if (PyObject_SetItem((PyObject *)dd, key, value) < 0) {
        Py_DECREF(value);
        return NULL;
    }
    return value;
}

Here is the call graph for this function:

static PyObject* defdict_reduce ( defdictobject dd) [static]

Definition at line 1310 of file _collectionsmodule.c.

{
    /* __reduce__ must return a 5-tuple as follows:

       - factory function
       - tuple of args for the factory function
       - additional state (here None)
       - sequence iterator (here None)
       - dictionary iterator (yielding successive (key, value) pairs

       This API is used by pickle.py and copy.py.

       For this to be useful with pickle.py, the default_factory
       must be picklable; e.g., None, a built-in, or a global
       function in a module or package.

       Both shallow and deep copying are supported, but for deep
       copying, the default_factory must be deep-copyable; e.g. None,
       or a built-in (functions are not copyable at this time).

       This only works for subclasses as long as their constructor
       signature is compatible; the first argument must be the
       optional default_factory, defaulting to None.
    */
    PyObject *args;
    PyObject *items;
    PyObject *iter;
    PyObject *result;
    if (dd->default_factory == NULL || dd->default_factory == Py_None)
        args = PyTuple_New(0);
    else
        args = PyTuple_Pack(1, dd->default_factory);
    if (args == NULL)
        return NULL;
    items = PyObject_CallMethod((PyObject *)dd, "items", "()");
    if (items == NULL) {
        Py_DECREF(args);
        return NULL;
    }
    iter = PyObject_GetIter(items);
    if (iter == NULL) {
        Py_DECREF(items);
        Py_DECREF(args);
        return NULL;
    }
    result = PyTuple_Pack(5, Py_TYPE(dd), args,
                          Py_None, Py_None, iter);
    Py_DECREF(iter);
    Py_DECREF(items);
    Py_DECREF(args);
    return result;
}

Here is the call graph for this function:

static PyObject* defdict_repr ( defdictobject dd) [static]

Definition at line 1390 of file _collectionsmodule.c.

{
    PyObject *baserepr;
    PyObject *defrepr;
    PyObject *result;
    baserepr = PyDict_Type.tp_repr((PyObject *)dd);
    if (baserepr == NULL)
        return NULL;
    if (dd->default_factory == NULL)
        defrepr = PyUnicode_FromString("None");
    else
    {
        int status = Py_ReprEnter(dd->default_factory);
        if (status != 0) {
            if (status < 0)
                return NULL;
            defrepr = PyUnicode_FromString("...");
        }
        else
            defrepr = PyObject_Repr(dd->default_factory);
        Py_ReprLeave(dd->default_factory);
    }
    if (defrepr == NULL) {
        Py_DECREF(baserepr);
        return NULL;
    }
    result = PyUnicode_FromFormat("defaultdict(%U, %U)",
                                  defrepr, baserepr);
    Py_DECREF(defrepr);
    Py_DECREF(baserepr);
    return result;
}

Here is the call graph for this function:

static int defdict_tp_clear ( defdictobject dd) [static]

Definition at line 1431 of file _collectionsmodule.c.

static int defdict_traverse ( PyObject self,
visitproc  visit,
void arg 
) [static]

Definition at line 1424 of file _collectionsmodule.c.

{
    Py_VISIT(((defdictobject *)self)->default_factory);
    return PyDict_Type.tp_traverse(self, visit, arg);
}
static PyObject* deque_append ( dequeobject deque,
PyObject item 
) [static]

Definition at line 234 of file _collectionsmodule.c.

{
    deque->state++;
    if (deque->rightindex == BLOCKLEN-1) {
        block *b = newblock(deque->rightblock, NULL, deque->len);
        if (b == NULL)
            return NULL;
        assert(deque->rightblock->rightlink == NULL);
        deque->rightblock->rightlink = b;
        deque->rightblock = b;
        deque->rightindex = -1;
    }
    Py_INCREF(item);
    deque->len++;
    deque->rightindex++;
    deque->rightblock->data[deque->rightindex] = item;
    TRIM(deque, deque_popleft);
    Py_RETURN_NONE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static PyObject* deque_appendleft ( dequeobject deque,
PyObject item 
) [static]

Definition at line 257 of file _collectionsmodule.c.

{
    deque->state++;
    if (deque->leftindex == 0) {
        block *b = newblock(NULL, deque->leftblock, deque->len);
        if (b == NULL)
            return NULL;
        assert(deque->leftblock->leftlink == NULL);
        deque->leftblock->leftlink = b;
        deque->leftblock = b;
        deque->leftindex = BLOCKLEN;
    }
    Py_INCREF(item);
    deque->len++;
    deque->leftindex--;
    deque->leftblock->data[deque->leftindex] = item;
    TRIM(deque, deque_pop);
    Py_RETURN_NONE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int deque_ass_item ( dequeobject deque,
Py_ssize_t  i,
PyObject v 
) [static]

Definition at line 670 of file _collectionsmodule.c.

{
    PyObject *old_value;
    block *b;
    Py_ssize_t n, len=deque->len, halflen=(len+1)>>1, index=i;

    if (i < 0 || i >= len) {
        PyErr_SetString(PyExc_IndexError,
                        "deque index out of range");
        return -1;
    }
    if (v == NULL)
        return deque_del_item(deque, i);

    i += deque->leftindex;
    n = i / BLOCKLEN;
    i %= BLOCKLEN;
    if (index <= halflen) {
        b = deque->leftblock;
        while (n--)
            b = b->rightlink;
    } else {
        n = (deque->leftindex + len - 1) / BLOCKLEN - n;
        b = deque->rightblock;
        while (n--)
            b = b->leftlink;
    }
    Py_INCREF(v);
    old_value = b->data[i];
    b->data[i] = v;
    Py_DECREF(old_value);
    return 0;
}

Here is the call graph for this function:

static int deque_clear ( dequeobject deque) [static]

Definition at line 592 of file _collectionsmodule.c.

{
    PyObject *item;

    while (deque->len) {
        item = deque_pop(deque, NULL);
        assert (item != NULL);
        Py_DECREF(item);
    }
    assert(deque->leftblock == deque->rightblock &&
           deque->leftindex - 1 == deque->rightindex &&
           deque->len == 0);
    return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static PyObject* deque_clearmethod ( dequeobject deque) [static]

Definition at line 705 of file _collectionsmodule.c.

{
    int rv;

    rv = deque_clear(deque);
    assert (rv != -1);
    Py_RETURN_NONE;
}

Here is the call graph for this function:

static PyObject* deque_copy ( PyObject deque) [static]

Definition at line 755 of file _collectionsmodule.c.

{
    if (((dequeobject *)deque)->maxlen == -1)
        return PyObject_CallFunction((PyObject *)(Py_TYPE(deque)), "O", deque, NULL);
    else
        return PyObject_CallFunction((PyObject *)(Py_TYPE(deque)), "Oi",
            deque, ((dequeobject *)deque)->maxlen, NULL);
}

Here is the call graph for this function:

static PyObject* deque_count ( dequeobject deque,
PyObject v 
) [static]

Definition at line 510 of file _collectionsmodule.c.

{
    block *leftblock = deque->leftblock;
    Py_ssize_t leftindex = deque->leftindex;
    Py_ssize_t n = deque->len;
    Py_ssize_t i;
    Py_ssize_t count = 0;
    PyObject *item;
    long start_state = deque->state;
    int cmp;

    for (i=0 ; i<n ; i++) {
        item = leftblock->data[leftindex];
        cmp = PyObject_RichCompareBool(item, v, Py_EQ);
        if (cmp > 0)
            count++;
        else if (cmp < 0)
            return NULL;

        if (start_state != deque->state) {
            PyErr_SetString(PyExc_RuntimeError,
                            "deque mutated during iteration");
            return NULL;
        }

        /* Advance left block/index pair */
        leftindex++;
        if (leftindex == BLOCKLEN) {
            if (leftblock->rightlink == NULL)  /* can occur when i==n-1 */
                break;
            leftblock = leftblock->rightlink;
            leftindex = 0;
        }
    }
    return PyLong_FromSsize_t(count);
}

Here is the call graph for this function:

static void deque_dealloc ( dequeobject deque) [static]

Definition at line 717 of file _collectionsmodule.c.

{
    PyObject_GC_UnTrack(deque);
    if (deque->weakreflist != NULL)
        PyObject_ClearWeakRefs((PyObject *) deque);
    if (deque->leftblock != NULL) {
        deque_clear(deque);
        assert(deque->leftblock != NULL);
        freeblock(deque->leftblock);
    }
    deque->leftblock = NULL;
    deque->rightblock = NULL;
    Py_TYPE(deque)->tp_free(deque);
}

Here is the call graph for this function:

static int deque_del_item ( dequeobject deque,
Py_ssize_t  i 
) [static]

Definition at line 654 of file _collectionsmodule.c.

{
    PyObject *item;

    assert (i >= 0 && i < deque->len);
    if (_deque_rotate(deque, -i) == -1)
        return -1;

    item = deque_popleft(deque, NULL);
    assert (item != NULL);
    Py_DECREF(item);

    return _deque_rotate(deque, i);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static PyObject* deque_extend ( dequeobject deque,
PyObject iterable 
) [static]

Definition at line 297 of file _collectionsmodule.c.

{
    PyObject *it, *item;

    /* Handle case where id(deque) == id(iterable) */
    if ((PyObject *)deque == iterable) {
        PyObject *result;
        PyObject *s = PySequence_List(iterable);
        if (s == NULL)
            return NULL;
        result = deque_extend(deque, s);
        Py_DECREF(s);
        return result;
    }

    it = PyObject_GetIter(iterable);
    if (it == NULL)
        return NULL;

    if (deque->maxlen == 0)
        return consume_iterator(it);

    while ((item = PyIter_Next(it)) != NULL) {
        deque->state++;
        if (deque->rightindex == BLOCKLEN-1) {
            block *b = newblock(deque->rightblock, NULL,
                                deque->len);
            if (b == NULL) {
                Py_DECREF(item);
                Py_DECREF(it);
                return NULL;
            }
            assert(deque->rightblock->rightlink == NULL);
            deque->rightblock->rightlink = b;
            deque->rightblock = b;
            deque->rightindex = -1;
        }
        deque->len++;
        deque->rightindex++;
        deque->rightblock->data[deque->rightindex] = item;
        TRIM(deque, deque_popleft);
    }
    Py_DECREF(it);
    if (PyErr_Occurred())
        return NULL;
    Py_RETURN_NONE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static PyObject* deque_extendleft ( dequeobject deque,
PyObject iterable 
) [static]

Definition at line 349 of file _collectionsmodule.c.

{
    PyObject *it, *item;

    /* Handle case where id(deque) == id(iterable) */
    if ((PyObject *)deque == iterable) {
        PyObject *result;
        PyObject *s = PySequence_List(iterable);
        if (s == NULL)
            return NULL;
        result = deque_extendleft(deque, s);
        Py_DECREF(s);
        return result;
    }

    it = PyObject_GetIter(iterable);
    if (it == NULL)
        return NULL;

    if (deque->maxlen == 0)
        return consume_iterator(it);

    while ((item = PyIter_Next(it)) != NULL) {
        deque->state++;
        if (deque->leftindex == 0) {
            block *b = newblock(NULL, deque->leftblock,
                                deque->len);
            if (b == NULL) {
                Py_DECREF(item);
                Py_DECREF(it);
                return NULL;
            }
            assert(deque->leftblock->leftlink == NULL);
            deque->leftblock->leftlink = b;
            deque->leftblock = b;
            deque->leftindex = BLOCKLEN;
        }
        deque->len++;
        deque->leftindex--;
        deque->leftblock->data[deque->leftindex] = item;
        TRIM(deque, deque_pop);
    }
    Py_DECREF(it);
    if (PyErr_Occurred())
        return NULL;
    Py_RETURN_NONE;
}

Here is the call graph for this function:

static PyObject* deque_get_maxlen ( dequeobject deque) [static]

Definition at line 936 of file _collectionsmodule.c.

{
    if (deque->maxlen == -1)
        Py_RETURN_NONE;
    return PyLong_FromSsize_t(deque->maxlen);
}
static int deque_init ( dequeobject deque,
PyObject args,
PyObject kwdargs 
) [static]

Definition at line 906 of file _collectionsmodule.c.

{
    PyObject *iterable = NULL;
    PyObject *maxlenobj = NULL;
    Py_ssize_t maxlen = -1;
    char *kwlist[] = {"iterable", "maxlen", 0};

    if (!PyArg_ParseTupleAndKeywords(args, kwdargs, "|OO:deque", kwlist, &iterable, &maxlenobj))
        return -1;
    if (maxlenobj != NULL && maxlenobj != Py_None) {
        maxlen = PyLong_AsSsize_t(maxlenobj);
        if (maxlen == -1 && PyErr_Occurred())
            return -1;
        if (maxlen < 0) {
            PyErr_SetString(PyExc_ValueError, "maxlen must be non-negative");
            return -1;
        }
    }
    deque->maxlen = maxlen;
    deque_clear(deque);
    if (iterable != NULL) {
        PyObject *rv = deque_extend(deque, iterable);
        if (rv == NULL)
            return -1;
        Py_DECREF(rv);
    }
    return 0;
}

Here is the call graph for this function:

static PyObject* deque_inplace_concat ( dequeobject deque,
PyObject other 
) [static]

Definition at line 401 of file _collectionsmodule.c.

{
    PyObject *result;

    result = deque_extend(deque, other);
    if (result == NULL)
        return result;
    Py_DECREF(result);
    Py_INCREF(deque);
    return (PyObject *)deque;
}

Here is the call graph for this function:

static PyObject* deque_item ( dequeobject deque,
Py_ssize_t  i 
) [static]

Definition at line 608 of file _collectionsmodule.c.

{
    block *b;
    PyObject *item;
    Py_ssize_t n, index=i;

    if (i < 0 || i >= deque->len) {
        PyErr_SetString(PyExc_IndexError,
                        "deque index out of range");
        return NULL;
    }

    if (i == 0) {
        i = deque->leftindex;
        b = deque->leftblock;
    } else if (i == deque->len - 1) {
        i = deque->rightindex;
        b = deque->rightblock;
    } else {
        i += deque->leftindex;
        n = i / BLOCKLEN;
        i %= BLOCKLEN;
        if (index < (deque->len >> 1)) {
            b = deque->leftblock;
            while (n--)
                b = b->rightlink;
        } else {
            n = (deque->leftindex + deque->len - 1) / BLOCKLEN - n;
            b = deque->rightblock;
            while (n--)
                b = b->leftlink;
        }
    }
    item = b->data[i];
    Py_INCREF(item);
    return item;
}

Here is the call graph for this function:

static PyObject * deque_iter ( dequeobject deque) [static]

Definition at line 1065 of file _collectionsmodule.c.

{
    dequeiterobject *it;

    it = PyObject_GC_New(dequeiterobject, &dequeiter_type);
    if (it == NULL)
        return NULL;
    it->b = deque->leftblock;
    it->index = deque->leftindex;
    Py_INCREF(deque);
    it->deque = deque;
    it->state = deque->state;
    it->counter = deque->len;
    PyObject_GC_Track(it);
    return (PyObject *)it;
}

Here is the call graph for this function:

static Py_ssize_t deque_len ( dequeobject deque) [static]

Definition at line 551 of file _collectionsmodule.c.

{
    return deque->len;
}
static PyObject* deque_new ( PyTypeObject type,
PyObject args,
PyObject kwds 
) [static]

Definition at line 130 of file _collectionsmodule.c.

{
    dequeobject *deque;
    block *b;

    /* create dequeobject structure */
    deque = (dequeobject *)type->tp_alloc(type, 0);
    if (deque == NULL)
        return NULL;

    b = newblock(NULL, NULL, 0);
    if (b == NULL) {
        Py_DECREF(deque);
        return NULL;
    }

    assert(BLOCKLEN >= 2);
    deque->leftblock = b;
    deque->rightblock = b;
    deque->leftindex = CENTER + 1;
    deque->rightindex = CENTER;
    deque->len = 0;
    deque->state = 0;
    deque->weakreflist = NULL;
    deque->maxlen = -1;

    return (PyObject *)deque;
}

Here is the call graph for this function:

static PyObject* deque_pop ( dequeobject deque,
PyObject unused 
) [static]

Definition at line 160 of file _collectionsmodule.c.

{
    PyObject *item;
    block *prevblock;

    if (deque->len == 0) {
        PyErr_SetString(PyExc_IndexError, "pop from an empty deque");
        return NULL;
    }
    item = deque->rightblock->data[deque->rightindex];
    deque->rightindex--;
    deque->len--;
    deque->state++;

    if (deque->rightindex == -1) {
        if (deque->len == 0) {
            assert(deque->leftblock == deque->rightblock);
            assert(deque->leftindex == deque->rightindex+1);
            /* re-center instead of freeing a block */
            deque->leftindex = CENTER + 1;
            deque->rightindex = CENTER;
        } else {
            prevblock = deque->rightblock->leftlink;
            assert(deque->leftblock != deque->rightblock);
            freeblock(deque->rightblock);
            prevblock->rightlink = NULL;
            deque->rightblock = prevblock;
            deque->rightindex = BLOCKLEN - 1;
        }
    }
    return item;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static PyObject* deque_popleft ( dequeobject deque,
PyObject unused 
) [static]

Definition at line 196 of file _collectionsmodule.c.

{
    PyObject *item;
    block *prevblock;

    if (deque->len == 0) {
        PyErr_SetString(PyExc_IndexError, "pop from an empty deque");
        return NULL;
    }
    assert(deque->leftblock != NULL);
    item = deque->leftblock->data[deque->leftindex];
    deque->leftindex++;
    deque->len--;
    deque->state++;

    if (deque->leftindex == BLOCKLEN) {
        if (deque->len == 0) {
            assert(deque->leftblock == deque->rightblock);
            assert(deque->leftindex == deque->rightindex+1);
            /* re-center instead of freeing a block */
            deque->leftindex = CENTER + 1;
            deque->rightindex = CENTER;
        } else {
            assert(deque->leftblock != deque->rightblock);
            prevblock = deque->leftblock->rightlink;
            freeblock(deque->leftblock);
            assert(prevblock != NULL);
            prevblock->leftlink = NULL;
            deque->leftblock = prevblock;
            deque->leftindex = 0;
        }
    }
    return item;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static PyObject* deque_reduce ( dequeobject deque) [static]

Definition at line 767 of file _collectionsmodule.c.

{
    PyObject *dict, *result, *aslist;

    dict = PyObject_GetAttrString((PyObject *)deque, "__dict__");
    if (dict == NULL)
        PyErr_Clear();
    aslist = PySequence_List((PyObject *)deque);
    if (aslist == NULL) {
        Py_XDECREF(dict);
        return NULL;
    }
    if (dict == NULL) {
        if (deque->maxlen == -1)
            result = Py_BuildValue("O(O)", Py_TYPE(deque), aslist);
        else
            result = Py_BuildValue("O(On)", Py_TYPE(deque), aslist, deque->maxlen);
    } else {
        if (deque->maxlen == -1)
            result = Py_BuildValue("O(OO)O", Py_TYPE(deque), aslist, Py_None, dict);
        else
            result = Py_BuildValue("O(On)O", Py_TYPE(deque), aslist, deque->maxlen, dict);
    }
    Py_XDECREF(dict);
    Py_DECREF(aslist);
    return result;
}

Here is the call graph for this function:

static PyObject* deque_remove ( dequeobject deque,
PyObject value 
) [static]

Definition at line 557 of file _collectionsmodule.c.

{
    Py_ssize_t i, n=deque->len;

    for (i=0 ; i<n ; i++) {
        PyObject *item = deque->leftblock->data[deque->leftindex];
        int cmp = PyObject_RichCompareBool(item, value, Py_EQ);

        if (deque->len != n) {
            PyErr_SetString(PyExc_IndexError,
                "deque mutated during remove().");
            return NULL;
        }
        if (cmp > 0) {
            PyObject *tgt = deque_popleft(deque, NULL);
            assert (tgt != NULL);
            Py_DECREF(tgt);
            if (_deque_rotate(deque, i) == -1)
                return NULL;
            Py_RETURN_NONE;
        }
        else if (cmp < 0) {
            _deque_rotate(deque, i);
            return NULL;
        }
        _deque_rotate(deque, -1);
    }
    PyErr_SetString(PyExc_ValueError, "deque.remove(x): x not in deque");
    return NULL;
}

Here is the call graph for this function:

static PyObject* deque_repr ( PyObject deque) [static]

Definition at line 798 of file _collectionsmodule.c.

{
    PyObject *aslist, *result;
    int i;

    i = Py_ReprEnter(deque);
    if (i != 0) {
        if (i < 0)
            return NULL;
        return PyUnicode_FromString("[...]");
    }

    aslist = PySequence_List(deque);
    if (aslist == NULL) {
        Py_ReprLeave(deque);
        return NULL;
    }
    if (((dequeobject *)deque)->maxlen != -1)

        result = PyUnicode_FromFormat("deque(%R, maxlen=%zd)",
                                      aslist, ((dequeobject *)deque)->maxlen);
    else
        result = PyUnicode_FromFormat("deque(%R)", aslist);
    Py_DECREF(aslist);
    Py_ReprLeave(deque);
    return result;
}

Here is the call graph for this function:

static PyObject* deque_reverse ( dequeobject deque,
PyObject unused 
) [static]

Definition at line 466 of file _collectionsmodule.c.

{
    block *leftblock = deque->leftblock;
    block *rightblock = deque->rightblock;
    Py_ssize_t leftindex = deque->leftindex;
    Py_ssize_t rightindex = deque->rightindex;
    Py_ssize_t n = (deque->len)/2;
    Py_ssize_t i;
    PyObject *tmp;

    for (i=0 ; i<n ; i++) {
        /* Validate that pointers haven't met in the middle */
        assert(leftblock != rightblock || leftindex < rightindex);

        /* Swap */
        tmp = leftblock->data[leftindex];
        leftblock->data[leftindex] = rightblock->data[rightindex];
        rightblock->data[rightindex] = tmp;

        /* Advance left block/index pair */
        leftindex++;
        if (leftindex == BLOCKLEN) {
            if (leftblock->rightlink == NULL)
                break;
            leftblock = leftblock->rightlink;
            leftindex = 0;
        }

        /* Step backwards with the right block/index pair */
        rightindex--;
        if (rightindex == -1) {
            if (rightblock->leftlink == NULL)
                break;
            rightblock = rightblock->leftlink;
            rightindex = BLOCKLEN - 1;
        }
    }
    Py_RETURN_NONE;
}
static PyObject * deque_reviter ( dequeobject deque) [static]

Definition at line 1175 of file _collectionsmodule.c.

{
    dequeiterobject *it;

    it = PyObject_GC_New(dequeiterobject, &dequereviter_type);
    if (it == NULL)
        return NULL;
    it->b = deque->rightblock;
    it->index = deque->rightindex;
    Py_INCREF(deque);
    it->deque = deque;
    it->state = deque->state;
    it->counter = deque->len;
    PyObject_GC_Track(it);
    return (PyObject *)it;
}

Here is the call graph for this function:

static PyObject* deque_richcompare ( PyObject v,
PyObject w,
int  op 
) [static]

Definition at line 827 of file _collectionsmodule.c.

{
    PyObject *it1=NULL, *it2=NULL, *x, *y;
    Py_ssize_t vs, ws;
    int b, cmp=-1;

    if (!PyObject_TypeCheck(v, &deque_type) ||
        !PyObject_TypeCheck(w, &deque_type)) {
        Py_INCREF(Py_NotImplemented);
        return Py_NotImplemented;
    }

    /* Shortcuts */
    vs = ((dequeobject *)v)->len;
    ws = ((dequeobject *)w)->len;
    if (op == Py_EQ) {
        if (v == w)
            Py_RETURN_TRUE;
        if (vs != ws)
            Py_RETURN_FALSE;
    }
    if (op == Py_NE) {
        if (v == w)
            Py_RETURN_FALSE;
        if (vs != ws)
            Py_RETURN_TRUE;
    }

    /* Search for the first index where items are different */
    it1 = PyObject_GetIter(v);
    if (it1 == NULL)
        goto done;
    it2 = PyObject_GetIter(w);
    if (it2 == NULL)
        goto done;
    for (;;) {
        x = PyIter_Next(it1);
        if (x == NULL && PyErr_Occurred())
            goto done;
        y = PyIter_Next(it2);
        if (x == NULL || y == NULL)
            break;
        b = PyObject_RichCompareBool(x, y, Py_EQ);
        if (b == 0) {
            cmp = PyObject_RichCompareBool(x, y, op);
            Py_DECREF(x);
            Py_DECREF(y);
            goto done;
        }
        Py_DECREF(x);
        Py_DECREF(y);
        if (b == -1)
            goto done;
    }
    /* We reached the end of one deque or both */
    Py_XDECREF(x);
    Py_XDECREF(y);
    if (PyErr_Occurred())
        goto done;
    switch (op) {
    case Py_LT: cmp = y != NULL; break;  /* if w was longer */
    case Py_LE: cmp = x == NULL; break;  /* if v was not longer */
    case Py_EQ: cmp = x == y;    break;  /* if we reached the end of both */
    case Py_NE: cmp = x != y;    break;  /* if one deque continues */
    case Py_GT: cmp = x != NULL; break;  /* if v was longer */
    case Py_GE: cmp = y == NULL; break;  /* if w was not longer */
    }

done:
    Py_XDECREF(it1);
    Py_XDECREF(it2);
    if (cmp == 1)
        Py_RETURN_TRUE;
    if (cmp == 0)
        Py_RETURN_FALSE;
    return NULL;
}

Here is the call graph for this function:

static PyObject* deque_rotate ( dequeobject deque,
PyObject args 
) [static]

Definition at line 451 of file _collectionsmodule.c.

{
    Py_ssize_t n=1;

    if (!PyArg_ParseTuple(args, "|n:rotate", &n))
        return NULL;
    if (_deque_rotate(deque, n) == 0)
        Py_RETURN_NONE;
    return NULL;
}

Here is the call graph for this function:

static int deque_traverse ( dequeobject deque,
visitproc  visit,
void arg 
) [static]

Definition at line 733 of file _collectionsmodule.c.

{
    block *b;
    PyObject *item;
    Py_ssize_t index;
    Py_ssize_t indexlo = deque->leftindex;

    for (b = deque->leftblock; b != NULL; b = b->rightlink) {
        const Py_ssize_t indexhi = b == deque->rightblock ?
                                 deque->rightindex :
                     BLOCKLEN - 1;

        for (index = indexlo; index <= indexhi; ++index) {
            item = b->data[index];
            Py_VISIT(item);
        }
        indexlo = 0;
    }
    return 0;
}
static void dequeiter_dealloc ( dequeiterobject dio) [static]

Definition at line 1090 of file _collectionsmodule.c.

{
    Py_XDECREF(dio->deque);
    PyObject_GC_Del(dio);
}

Here is the call graph for this function:

static PyObject* dequeiter_len ( dequeiterobject it) [static]

Definition at line 1125 of file _collectionsmodule.c.

{
    return PyLong_FromSsize_t(it->counter);
}
static PyObject* dequeiter_next ( dequeiterobject it) [static]

Definition at line 1097 of file _collectionsmodule.c.

{
    PyObject *item;

    if (it->deque->state != it->state) {
        it->counter = 0;
        PyErr_SetString(PyExc_RuntimeError,
                        "deque mutated during iteration");
        return NULL;
    }
    if (it->counter == 0)
        return NULL;
    assert (!(it->b == it->deque->rightblock &&
              it->index > it->deque->rightindex));

    item = it->b->data[it->index];
    it->index++;
    it->counter--;
    if (it->index == BLOCKLEN && it->counter > 0) {
        assert (it->b->rightlink != NULL);
        it->b = it->b->rightlink;
        it->index = 0;
    }
    Py_INCREF(item);
    return item;
}

Here is the call graph for this function:

static int dequeiter_traverse ( dequeiterobject dio,
visitproc  visit,
void arg 
) [static]

Definition at line 1083 of file _collectionsmodule.c.

{
    Py_VISIT(dio->deque);
    return 0;
}
static PyObject* dequereviter_next ( dequeiterobject it) [static]

Definition at line 1193 of file _collectionsmodule.c.

{
    PyObject *item;
    if (it->counter == 0)
        return NULL;

    if (it->deque->state != it->state) {
        it->counter = 0;
        PyErr_SetString(PyExc_RuntimeError,
                        "deque mutated during iteration");
        return NULL;
    }
    assert (!(it->b == it->deque->leftblock &&
              it->index < it->deque->leftindex));

    item = it->b->data[it->index];
    it->index--;
    it->counter--;
    if (it->index == -1 && it->counter > 0) {
        assert (it->b->leftlink != NULL);
        it->b = it->b->leftlink;
        it->index = BLOCKLEN - 1;
    }
    Py_INCREF(item);
    return item;
}

Here is the call graph for this function:

static void freeblock ( block b) [static]

Definition at line 89 of file _collectionsmodule.c.

Here is the call graph for this function:

Here is the caller graph for this function:

static block* newblock ( block leftlink,
block rightlink,
Py_ssize_t  len 
) [static]

Definition at line 59 of file _collectionsmodule.c.

                                                            {
    block *b;
    /* To prevent len from overflowing PY_SSIZE_T_MAX on 64-bit machines, we
     * refuse to allocate new blocks if the current len is dangerously
     * close.  There is some extra margin to prevent spurious arithmetic
     * overflows at various places.  The following check ensures that
     * the blocks allocated to the deque, in the worst case, can only
     * have PY_SSIZE_T_MAX-2 entries in total.
     */
    if (len >= PY_SSIZE_T_MAX - 2*BLOCKLEN) {
        PyErr_SetString(PyExc_OverflowError,
                        "cannot add more blocks to the deque");
        return NULL;
    }
    if (numfreeblocks) {
        numfreeblocks -= 1;
        b = freeblocks[numfreeblocks];
    } else {
        b = PyMem_Malloc(sizeof(block));
        if (b == NULL) {
            PyErr_NoMemory();
            return NULL;
        }
    }
    b->leftlink = leftlink;
    b->rightlink = rightlink;
    return b;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PyDoc_STRVAR ( pop_doc  ,
"Remove and return the rightmost element."   
)
PyDoc_STRVAR ( popleft_doc  ,
"Remove and return the leftmost element."   
)
PyDoc_STRVAR ( append_doc  ,
"Add an element to the right side of the deque."   
)
PyDoc_STRVAR ( appendleft_doc  ,
"Add an element to the left side of the deque."   
)
PyDoc_STRVAR ( extend_doc  ,
"Extend the right side of the deque with elements from the iterable  
)
PyDoc_STRVAR ( extendleft_doc  ,
"Extend the left side of the deque with elements from the iterable  
)
PyDoc_STRVAR ( rotate_doc  ,
"Rotate the deque n steps to the right (default n=1). If n is  negative,
rotates left."   
)
PyDoc_STRVAR ( reverse_doc  ,
"D.reverse() -- reverse *IN PLACE*"   
)
PyDoc_STRVAR ( count_doc  ,
"D.count(value) -> integer -- return number of occurrences of value  
)
PyDoc_STRVAR ( remove_doc  ,
"D.remove(value) -- remove first occurrence of value."   
)
PyDoc_STRVAR ( clear_doc  ,
"Remove all elements from the deque."   
)
PyDoc_STRVAR ( copy_doc  ,
"Return a shallow copy of a deque."   
)
PyDoc_STRVAR ( reduce_doc  ,
"Return state information for pickling."   
)
PyDoc_STRVAR ( reversed_doc  ,
"D.__reversed__() -- return a reverse iterator over the deque"   
)
PyDoc_STRVAR ( deque_doc  ,
"deque(iterable[, maxlen]) --> deque object\n\\n\Build an ordered collection with optimized access from its endpoints."   
)
PyDoc_STRVAR ( length_hint_doc  ,
"Private method returning an estimate of len(list(it))."   
)
PyDoc_STRVAR ( defdict_missing_doc  )
PyDoc_STRVAR ( defdict_copy_doc  ,
"D.copy() -> a shallow copy of D."   
)
PyDoc_STRVAR ( defdict_doc  ,
"defaultdict(default_factory) --> dict with default factory\n\\n\The default factory is called without arguments to produce\n\a new value when a key is not  present,
in __getitem__ only.\n\A defaultdict compares equal to a dict with the same items.\n\"   
)
PyDoc_STRVAR ( _count_elements_doc  ,
"_count_elements(mapping, iterable) -> None\n\\n\Count elements in the  iterable,
updating the mappping"   
)
PyDoc_STRVAR ( module_doc  ,
"High performance data structures.\n\- deque: ordered collection accessible from endpoints only\n\- defaultdict: dict subclass with a default value factory\n\"   
)

Definition at line 1639 of file _collectionsmodule.c.

{
    PyObject *m;

    m = PyModule_Create(&_collectionsmodule);
    if (m == NULL)
        return NULL;

    if (PyType_Ready(&deque_type) < 0)
        return NULL;
    Py_INCREF(&deque_type);
    PyModule_AddObject(m, "deque", (PyObject *)&deque_type);

    defdict_type.tp_base = &PyDict_Type;
    if (PyType_Ready(&defdict_type) < 0)
        return NULL;
    Py_INCREF(&defdict_type);
    PyModule_AddObject(m, "defaultdict", (PyObject *)&defdict_type);

    if (PyType_Ready(&dequeiter_type) < 0)
        return NULL;

    if (PyType_Ready(&dequereviter_type) < 0)
        return NULL;

    return m;
}

Here is the call graph for this function:


Variable Documentation

Initial value:
 {
    {"default_factory", T_OBJECT,
     offsetof(defdictobject, default_factory), 0,
     PyDoc_STR("Factory for default value called by __missing__().")},
    {NULL}
}

Definition at line 1375 of file _collectionsmodule.c.

Initial value:
 {
    {"__missing__", (PyCFunction)defdict_missing, METH_O,
     defdict_missing_doc},
    {"copy", (PyCFunction)defdict_copy, METH_NOARGS,
     defdict_copy_doc},
    {"__copy__", (PyCFunction)defdict_copy, METH_NOARGS,
     defdict_copy_doc},
    {"__reduce__", (PyCFunction)defdict_reduce, METH_NOARGS,
     reduce_doc},
    {NULL}
}

Definition at line 1363 of file _collectionsmodule.c.

static PyTypeObject defdict_type [static]

Definition at line 1260 of file _collectionsmodule.c.

Initial value:

Definition at line 949 of file _collectionsmodule.c.

Initial value:
 {
    {"maxlen", (getter)deque_get_maxlen, (setter)NULL,
     "maximum size of a deque or None if unbounded"},
    {0}
}

Definition at line 943 of file _collectionsmodule.c.

Definition at line 970 of file _collectionsmodule.c.

static PyTypeObject deque_type [static]

Definition at line 127 of file _collectionsmodule.c.

Initial value:
 {
    {"__length_hint__", (PyCFunction)dequeiter_len, METH_NOARGS, length_hint_doc},
    {NULL,              NULL}           
}

Definition at line 1132 of file _collectionsmodule.c.

static PyTypeObject dequeiter_type [static]

Definition at line 1062 of file _collectionsmodule.c.

Definition at line 1172 of file _collectionsmodule.c.

Definition at line 56 of file _collectionsmodule.c.

Py_ssize_t numfreeblocks = 0 [static]

Definition at line 55 of file _collectionsmodule.c.

struct PyMethodDef[] [static]
Initial value:
 {
    {"_count_elements", _count_elements,    METH_VARARGS,   _count_elements_doc},
    {NULL,       NULL}          
}

Definition at line 1621 of file _collectionsmodule.c.

struct PyModuleDef [static]
Initial value:
 {
    PyModuleDef_HEAD_INIT,
    "_collections",
    module_doc,
    -1,
    module_functions,
    NULL,
    NULL,
    NULL,
    NULL
}

Definition at line 1626 of file _collectionsmodule.c.