summaryrefslogtreecommitdiffstats
path: root/Objects/sliceobject.c
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2007-04-11 18:40:58 (GMT)
committerRaymond Hettinger <python@rcn.com>2007-04-11 18:40:58 (GMT)
commit13936697f60feedd560d16c94e2524453bb1255a (patch)
treeb32c9dd1d973b430e24d8bdc5dc8f2d27317102a /Objects/sliceobject.c
parentc02e13122ba94b05dc03fd56de393b9129f3ed25 (diff)
downloadcpython-13936697f60feedd560d16c94e2524453bb1255a.zip
cpython-13936697f60feedd560d16c94e2524453bb1255a.tar.gz
cpython-13936697f60feedd560d16c94e2524453bb1255a.tar.bz2
SF 1191699: Make slices picklable
Diffstat (limited to 'Objects/sliceobject.c')
-rw-r--r--Objects/sliceobject.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/Objects/sliceobject.c b/Objects/sliceobject.c
index d8a2465..3fb1430 100644
--- a/Objects/sliceobject.c
+++ b/Objects/sliceobject.c
@@ -274,9 +274,19 @@ indices, and the stride length of the extended slice described by\n\
S. Out of bounds indices are clipped in a manner consistent with the\n\
handling of normal slices.");
+static PyObject *
+slice_reduce(PySliceObject* self)
+{
+ return Py_BuildValue("O(OOO)", self->ob_type, self->start, self->stop, self->step);
+}
+
+PyDoc_STRVAR(reduce_doc, "Return state information for pickling.");
+
static PyMethodDef slice_methods[] = {
{"indices", (PyCFunction)slice_indices,
METH_O, slice_indices_doc},
+ {"__reduce__", (PyCFunction)slice_reduce,
+ METH_NOARGS, reduce_doc},
{NULL, NULL}
};