Added buffer_info() method that returns address and length in bytes of

the buffer used to hold the array -- for dangerous low-level I/O.
This commit is contained in:
Guido van Rossum 1997-08-12 14:55:56 +00:00
parent ea46e4d93c
commit de4a4ca2dd
1 changed files with 10 additions and 0 deletions

View File

@ -711,6 +711,15 @@ array_insert(self, args)
return ins(self, i, v); return ins(self, i, v);
} }
static PyObject *
array_buffer_info(self, args)
arrayobject *self;
PyObject *args;
{
return Py_BuildValue("ll",
(long)(self->ob_item), (long)(self->ob_size));
}
static PyObject * static PyObject *
array_append(self, args) array_append(self, args)
arrayobject *self; arrayobject *self;
@ -1050,6 +1059,7 @@ array_tostring(self, args)
static PyMethodDef array_methods[] = { static PyMethodDef array_methods[] = {
{"append", (PyCFunction)array_append}, {"append", (PyCFunction)array_append},
{"buffer_info", (PyCFunction)array_buffer_info},
{"byteswap", (PyCFunction)array_byteswap}, {"byteswap", (PyCFunction)array_byteswap},
/* {"count", (method)array_count},*/ /* {"count", (method)array_count},*/
{"fromfile", (PyCFunction)array_fromfile}, {"fromfile", (PyCFunction)array_fromfile},