typedef struct {
PyObject_HEAD
PyObject *it;
- long next;
- long stop;
- long step;
- long cnt;
+ Py_ssize_t next;
+ Py_ssize_t stop;
+ Py_ssize_t step;
+ Py_ssize_t cnt;
} isliceobject;
static PyTypeObject islice_type;
islice_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
PyObject *seq;
- long start=0, stop=-1, step=1;
+ Py_ssize_t start=0, stop=-1, step=1;
PyObject *it, *a1=NULL, *a2=NULL, *a3=NULL;
Py_ssize_t numargs;
isliceobject *lz;
numargs = PyTuple_Size(args);
if (numargs == 2) {
if (a1 != Py_None) {
- stop = PyInt_AsLong(a1);
+ stop = PyInt_AsSsize_t(a1);
if (stop == -1) {
if (PyErr_Occurred())
PyErr_Clear();
}
} else {
if (a1 != Py_None)
- start = PyInt_AsLong(a1);
+ start = PyInt_AsSsize_t(a1);
if (start == -1 && PyErr_Occurred())
PyErr_Clear();
if (a2 != Py_None) {
- stop = PyInt_AsLong(a2);
+ stop = PyInt_AsSsize_t(a2);
if (stop == -1) {
if (PyErr_Occurred())
PyErr_Clear();
if (a3 != NULL) {
if (a3 != Py_None)
- step = PyInt_AsLong(a3);
+ step = PyInt_AsSsize_t(a3);
if (step == -1 && PyErr_Occurred())
PyErr_Clear();
}
{
PyObject *item;
PyObject *it = lz->it;
- long oldnext;
+ Py_ssize_t oldnext;
PyObject *(*iternext)(PyObject *);
assert(PyIter_Check(it));
typedef struct {
PyObject_HEAD
- Py_ssize_t tuplesize;
- long iternum; /* which iterator is active */
+ Py_ssize_t tuplesize;
+ Py_ssize_t iternum; /* which iterator is active */
PyObject *ittuple; /* tuple of iterators */
} chainobject;
{
chainobject *lz;
Py_ssize_t tuplesize = PySequence_Length(args);
- int i;
+ Py_ssize_t i;
PyObject *ittuple;
if (!_PyArg_NoKeywords("chain()", kwds))
typedef struct {
PyObject_HEAD
- long cnt;
+ Py_ssize_t cnt;
} countobject;
static PyTypeObject count_type;
count_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
countobject *lz;
- long cnt = 0;
+ Py_ssize_t cnt = 0;
if (!_PyArg_NoKeywords("count()", kwds))
return NULL;
- if (!PyArg_ParseTuple(args, "|l:count", &cnt))
+ if (!PyArg_ParseTuple(args, "|n:count", &cnt))
return NULL;
/* create countobject structure */
static PyObject *
count_next(countobject *lz)
{
- return PyInt_FromLong(lz->cnt++);
+ return PyInt_FromSize_t(lz->cnt++);
}
static PyObject *
count_repr(countobject *lz)
{
- return PyString_FromFormat("count(%ld)", lz->cnt);
+ return PyString_FromFormat("count(%zd)", lz->cnt);
}
PyDoc_STRVAR(count_doc,
izip_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
izipobject *lz;
- int i;
+ Py_ssize_t i;
PyObject *ittuple; /* tuple of iterators */
PyObject *result;
Py_ssize_t tuplesize = PySequence_Length(args);
static PyObject *
izip_next(izipobject *lz)
{
- int i;
+ Py_ssize_t i;
Py_ssize_t tuplesize = lz->tuplesize;
PyObject *result = lz->result;
PyObject *it;
typedef struct {
PyObject_HEAD
PyObject *element;
- long cnt;
+ Py_ssize_t cnt;
} repeatobject;
static PyTypeObject repeat_type;
{
repeatobject *ro;
PyObject *element;
- long cnt = -1;
+ Py_ssize_t cnt = -1;
if (!_PyArg_NoKeywords("repeat()", kwds))
return NULL;
- if (!PyArg_ParseTuple(args, "O|l:repeat", &element, &cnt))
+ if (!PyArg_ParseTuple(args, "O|n:repeat", &element, &cnt))
return NULL;
if (PyTuple_Size(args) == 2 && cnt < 0)
result = PyString_FromFormat("repeat(%s)",
PyString_AS_STRING(objrepr));
else
- result = PyString_FromFormat("repeat(%s, %ld)",
+ result = PyString_FromFormat("repeat(%s, %zd)",
PyString_AS_STRING(objrepr), ro->cnt);
Py_DECREF(objrepr);
return result;
PyErr_SetString(PyExc_TypeError, "len() of unsized object");
return NULL;
}
- return PyInt_FromLong(ro->cnt);
+ return PyInt_FromSize_t(ro->cnt);
}
PyDoc_STRVAR(length_hint_doc, "Private method returning an estimate of len(list(it)).");