equivalent to the Python expression: type(o).
*/
- DL_IMPORT(int) PyObject_Length(PyObject *o);
+ DL_IMPORT(int) PyObject_Size(PyObject *o);
+
+#define PyObject_Length(O) PyObject_Size((O))
/*
- Return the length of object o. If the object, o, provides
- both sequence and mapping protocols, the sequence length is
+ Return the size of object o. If the object, o, provides
+ both sequence and mapping protocols, the sequence size is
returned. On error, -1 is returned. This is the equivalent
to the Python expression: len(o).
*/
- DL_IMPORT(int) PySequence_Length(PyObject *o);
+ DL_IMPORT(int) PySequence_Size(PyObject *o);
+
+#define PySequence_Length(O) PySequence_Size((O))
/*
- Return the length of sequence object o, or -1 on failure.
+ Return the size of sequence object o, or -1 on failure.
*/
This function always succeeds.
*/
- DL_IMPORT(int) PyMapping_Length(PyObject *o);
+ DL_IMPORT(int) PyMapping_Size(PyObject *o);
+
+#define PyMapping_Length(O) PyMapping_Size((O))
/*
Returns the number of keys in object o on success, and -1 on
}
int
-PyObject_Length(PyObject *o)
+PyObject_Size(PyObject *o)
{
PySequenceMethods *m;
if (m && m->sq_length)
return m->sq_length(o);
- return PyMapping_Length(o);
+ return PyMapping_Size(o);
}
PyObject *
}
int
-PySequence_Length(PyObject *s)
+PySequence_Size(PyObject *s)
{
PySequenceMethods *m;
if (m && m->sq_item) {
int i;
PyObject *t;
- int n = PySequence_Length(v);
+ int n = PySequence_Size(v);
if (n < 0)
return NULL;
t = PyTuple_New(n);
if (m && m->sq_item) {
int i;
PyObject *l;
- int n = PySequence_Length(v);
+ int n = PySequence_Size(v);
if (n < 0)
return NULL;
l = PyList_New(n);
return -1;
}
- l = PySequence_Length(s);
+ l = PySequence_Size(s);
if (l < 0)
return -1;
return -1;
}
- l = PySequence_Length(s);
+ l = PySequence_Size(s);
if (l < 0)
return -1;
}
int
-PyMapping_Length(PyObject *o)
+PyMapping_Size(PyObject *o)
{
PyMappingMethods *m;
/* Hack to force loading of abstract.o */
-int (*_Py_abstract_hack)(PyObject *) = &PyObject_Length;
+int (*_Py_abstract_hack)(PyObject *) = &PyObject_Size;
/* Python's malloc wrappers (see mymalloc.h) */