Implement appropriate __getnewargs__ for all immutable subclassable builtin
types. The special handling for these can now be removed from save_newobj().
Add some testing for this.
Also add support for setting the 'fast' flag on the Python Pickler class,
which suppresses use of the memo.
diff --git a/Objects/floatobject.c b/Objects/floatobject.c
index 09406e4..6e65756 100644
--- a/Objects/floatobject.c
+++ b/Objects/floatobject.c
@@ -726,6 +726,17 @@
return new;
}
+static PyObject *
+float_getnewargs(PyFloatObject *v)
+{
+ return Py_BuildValue("(d)", v->ob_fval);
+}
+
+static PyMethodDef float_methods[] = {
+ {"__getnewargs__", (PyCFunction)float_getnewargs, METH_NOARGS},
+ {NULL, NULL} /* sentinel */
+};
+
PyDoc_STRVAR(float_doc,
"float(x) -> floating point number\n\
\n\
@@ -803,7 +814,7 @@
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
- 0, /* tp_methods */
+ float_methods, /* tp_methods */
0, /* tp_members */
0, /* tp_getset */
0, /* tp_base */