Lines Matching defs:po

78     pairwiseobject *po;
84 po = (pairwiseobject *)type->tp_alloc(type, 0);
85 if (po == NULL) {
89 po->it = it;
90 po->old = NULL;
91 return (PyObject *)po;
95 pairwise_dealloc(pairwiseobject *po)
97 PyObject_GC_UnTrack(po);
98 Py_XDECREF(po->it);
99 Py_XDECREF(po->old);
100 Py_TYPE(po)->tp_free(po);
104 pairwise_traverse(pairwiseobject *po, visitproc visit, void *arg)
106 Py_VISIT(po->it);
107 Py_VISIT(po->old);
112 pairwise_next(pairwiseobject *po)
114 PyObject *it = po->it;
115 PyObject *old = po->old;
122 po->old = old = (*Py_TYPE(it)->tp_iternext)(it);
124 Py_CLEAR(po->it);
130 Py_CLEAR(po->it);
131 Py_CLEAR(po->old);
136 Py_SETREF(po->old, new);
3264 permutationsobject *po;
3305 po = (permutationsobject *)type->tp_alloc(type, 0);
3306 if (po == NULL)
3309 po->pool = pool;
3310 po->indices = indices;
3311 po->cycles = cycles;
3312 po->result = NULL;
3313 po->r = r;
3314 po->stopped = r > n ? 1 : 0;
3316 return (PyObject *)po;
3328 permutations_dealloc(permutationsobject *po)
3330 PyObject_GC_UnTrack(po);
3331 Py_XDECREF(po->pool);
3332 Py_XDECREF(po->result);
3333 PyMem_Free(po->indices);
3334 PyMem_Free(po->cycles);
3335 Py_TYPE(po)->tp_free(po);
3339 permutations_sizeof(permutationsobject *po, void *unused)
3343 res = _PyObject_SIZE(Py_TYPE(po));
3344 res += PyTuple_GET_SIZE(po->pool) * sizeof(Py_ssize_t);
3345 res += po->r * sizeof(Py_ssize_t);
3350 permutations_traverse(permutationsobject *po, visitproc visit, void *arg)
3352 Py_VISIT(po->pool);
3353 Py_VISIT(po->result);
3358 permutations_next(permutationsobject *po)
3362 PyObject *pool = po->pool;
3363 Py_ssize_t *indices = po->indices;
3364 Py_ssize_t *cycles = po->cycles;
3365 PyObject *result = po->result;
3367 Py_ssize_t r = po->r;
3370 if (po->stopped)
3378 po->result = result;
3395 po->result = result;
3444 po->stopped = 1;
3449 permutations_reduce(permutationsobject *po, PyObject *Py_UNUSED(ignored))
3451 if (po->result == NULL) {
3452 return Py_BuildValue("O(On)", Py_TYPE(po), po->pool, po->r);
3453 } else if (po->stopped) {
3454 return Py_BuildValue("O(()n)", Py_TYPE(po), po->r);
3460 n = PyTuple_GET_SIZE(po->pool);
3465 PyObject* index = PyLong_FromSsize_t(po->indices[i]);
3471 cycles = PyTuple_New(po->r);
3474 for (i=0 ; i<po->r ; i++) {
3475 PyObject* index = PyLong_FromSsize_t(po->cycles[i]);
3480 return Py_BuildValue("O(On)(NN)", Py_TYPE(po),
3481 po->pool, po->r,
3491 permutations_setstate(permutationsobject *po, PyObject *state)
3506 n = PyTuple_GET_SIZE(po->pool);
3507 if (PyTuple_GET_SIZE(indices) != n || PyTuple_GET_SIZE(cycles) != po->r) {
3522 po->indices[i] = index;
3525 for (i=0; i<po->r; i++) {
3534 po->cycles[i] = index;
3536 result = PyTuple_New(po->r);
3539 for (i=0; i<po->r; i++) {
3540 PyObject *element = PyTuple_GET_ITEM(po->pool, po->indices[i]);
3544 Py_XSETREF(po->result, result);