diff -r 403565c0e5de Python/marshal.c --- a/Python/marshal.c Tue Jan 28 02:24:22 2014 +0100 +++ b/Python/marshal.c Tue Jan 28 11:09:41 2014 +0100 @@ -235,6 +235,11 @@ w_ref(PyObject *v, char *flag, WFILE *p) if (Py_REFCNT(v) == 1) return 0; + /* Storing duplicated numbers has a low impact on output size, whereas it + has an impact cost in the serialization performance */ + if (PyLong_CheckExact(v) || PyFloat_CheckExact(v)) + return 0; + id = PyLong_FromVoidPtr((void*)v); if (id == NULL) goto err;