]> granicus.if.org Git - python/commitdiff
Added buffer_info() method that returns address and length in bytes of
authorGuido van Rossum <guido@python.org>
Tue, 12 Aug 1997 14:55:56 +0000 (14:55 +0000)
committerGuido van Rossum <guido@python.org>
Tue, 12 Aug 1997 14:55:56 +0000 (14:55 +0000)
the buffer used to hold the array -- for dangerous low-level I/O.

Modules/arraymodule.c

index debd59418f466b85c1fdf976b0b8fc873814e49a..6920cbfd400fc7d89ebe64c197f141c40389565e 100644 (file)
@@ -711,6 +711,15 @@ array_insert(self, args)
        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 *
 array_append(self, args)
        arrayobject *self;
@@ -1050,6 +1059,7 @@ array_tostring(self, args)
 
 static PyMethodDef array_methods[] = {
        {"append",      (PyCFunction)array_append},
+       {"buffer_info", (PyCFunction)array_buffer_info},
        {"byteswap",    (PyCFunction)array_byteswap},
 /*     {"count",       (method)array_count},*/
        {"fromfile",    (PyCFunction)array_fromfile},