<commit_before>diff -r 92003d9aae0e Include/objimpl.h
--- a/Include/objimpl.h	Tue Feb 26 12:37:07 2013 +0000
+++ b/Include/objimpl.h	Fri Mar 22 12:01:53 2013 +0100
@@ -98,10 +98,15 @@ PyAPI_FUNC(void *) PyObject_Malloc(size_
 PyAPI_FUNC(void *) PyObject_Realloc(void *, size_t);
 PyAPI_FUNC(void) PyObject_Free(void *);
 
+PyAPI_FUNC(int) _PyFreeList_SetAllocators(
+    void (*alloc) (PyObject *),
+    void (*free) (PyObject *)
+);
 
-/* Macros */
-#ifdef WITH_PYMALLOC
-#ifdef PYMALLOC_DEBUG   /* WITH_PYMALLOC && PYMALLOC_DEBUG */
+PyAPI_FUNC(void) _PyFreeList_Alloc(void *);
+PyAPI_FUNC(void) _PyFreeList_Free(void *);
+
+#if defined(WITH_PYMALLOC) && defined(PYMALLOC_DEBUG)
 PyAPI_FUNC(void *) _PyObject_DebugMalloc(size_t nbytes);
 PyAPI_FUNC(void *) _PyObject_DebugRealloc(void *p, size_t nbytes);
 PyAPI_FUNC(void) _PyObject_DebugFree(void *p);
@@ -115,28 +120,14 @@ PyAPI_FUNC(void) _PyObject_DebugCheckAdd
 PyAPI_FUNC(void *) _PyMem_DebugMalloc(size_t nbytes);
 PyAPI_FUNC(void *) _PyMem_DebugRealloc(void *p, size_t nbytes);
 PyAPI_FUNC(void) _PyMem_DebugFree(void *p);
-#define PyObject_MALLOC         _PyObject_DebugMalloc
-#define PyObject_Malloc         _PyObject_DebugMalloc
-#define PyObject_REALLOC        _PyObject_DebugRealloc
-#define PyObject_Realloc        _PyObject_DebugRealloc
-#define PyObject_FREE           _PyObject_DebugFree
-#define PyObject_Free           _PyObject_DebugFree
+#endif
 
-#else   /* WITH_PYMALLOC && ! PYMALLOC_DEBUG */
+/* Macros */
 #define PyObject_MALLOC         PyObject_Malloc
 #define PyObject_REALLOC        PyObject_Realloc
 #define PyObject_FREE           PyObject_Free
-#endif
-
-#else   /* ! WITH_PYMALLOC */
-#define PyObject_MALLOC         PyMem_MALLOC
-#define PyObject_REALLOC        PyMem_REALLOC
-#define PyObject_FREE           PyMem_FREE
-
-#endif  /* WITH_PYMALLOC */
-
 #define PyObject_Del            PyObject_Free
-#define PyObject_DEL            PyObject_FREE
+#define PyObject_DEL            PyObject_Free
 
 /* for source compatibility with 2.2 */
 #define _PyObject_Del           PyObject_Free
diff -r 92003d9aae0e Include/pymem.h
--- a/Include/pymem.h	Tue Feb 26 12:37:07 2013 +0000
+++ b/Include/pymem.h	Fri Mar 22 12:01:53 2013 +0100
@@ -49,6 +49,24 @@ extern "C" {
    performed on failure (no exception is set, no warning is printed, etc).
 */
 
+#define PY_ALLOC_SYSTEM_API 's'   /* the system API (malloc, realloc, free) */
+#define PY_ALLOC_MEM_API 'm'      /* the PyMem_Malloc() API */
+#define PY_ALLOC_OBJECT_API 'o'   /* The PyObject_Malloc() API */
+
+PyAPI_FUNC(int) Py_GetAllocators(
+    char api,
+    void* (**malloc_p) (size_t),
+    void* (**realloc_p) (void*, size_t),
+    void (**free_p) (void*)
+    );
+
+PyAPI_FUNC(int) Py_SetAllocators(
+    char api,
+    void* (*malloc) (size_t),
+    void* (*realloc) (void*, size_t),
+    void (*free) (void*)
+    );
+
 PyAPI_FUNC(void *) PyMem_Malloc(size_t);
 PyAPI_FUNC(void *) PyMem_Realloc(void *, size_t);
 PyAPI_FUNC(void) PyMem_Free(void *);
@@ -57,13 +75,6 @@ PyAPI_FUNC(void) PyMem_Free(void *);
    no longer supported. They used to call PyErr_NoMemory() on failure. */
 
 /* Macros. */
-#ifdef PYMALLOC_DEBUG
-/* Redirect all memory operations to Python's debugging allocator. */
-#define PyMem_MALLOC		_PyMem_DebugMalloc
-#define PyMem_REALLOC		_PyMem_DebugRealloc
-#define PyMem_FREE		_PyMem_DebugFree
-
-#else	/* ! PYMALLOC_DEBUG */
 
 /* PyMem_MALLOC(0) means malloc(1). Some systems would return NULL
    for malloc(0), which would be treated as an error. Some platforms
@@ -71,13 +82,9 @@ PyAPI_FUNC(void) PyMem_Free(void *);
    pymalloc. To solve these problems, allocate an extra byte. */
 /* Returns NULL to indicate error if a negative size or size larger than
    Py_ssize_t can represent is supplied.  Helps prevents security holes. */
-#define PyMem_MALLOC(n)		((size_t)(n) > (size_t)PY_SSIZE_T_MAX ? NULL \
-				: malloc((n) ? (n) : 1))
-#define PyMem_REALLOC(p, n)	((size_t)(n) > (size_t)PY_SSIZE_T_MAX  ? NULL \
-				: realloc((p), (n) ? (n) : 1))
-#define PyMem_FREE		free
-
-#endif	/* PYMALLOC_DEBUG */
+#define PyMem_MALLOC(n)		PyMem_Malloc(n)
+#define PyMem_REALLOC(p, n)	PyMem_Realloc(p, n)
+#define PyMem_FREE(p)		PyMem_Free(p)
 
 /*
  * Type-oriented memory interface
diff -r 92003d9aae0e Lib/test/regrtest.py
--- a/Lib/test/regrtest.py	Tue Feb 26 12:37:07 2013 +0000
+++ b/Lib/test/regrtest.py	Fri Mar 22 12:01:53 2013 +0100
@@ -1,4 +1,8 @@
 #! /usr/bin/env python
+import tracemalloc
+tracemalloc.enable()
+top = tracemalloc.DisplayTop(5)
+top.start(2)
 
 """
 Usage:
diff -r 92003d9aae0e Objects/classobject.c
--- a/Objects/classobject.c	Tue Feb 26 12:37:07 2013 +0000
+++ b/Objects/classobject.c	Fri Mar 22 12:01:53 2013 +0100
@@ -2257,6 +2257,7 @@ PyMethod_New(PyObject *func, PyObject *s
     if (im != NULL) {
         free_list = (PyMethodObject *)(im->im_self);
         PyObject_INIT(im, &PyMethod_Type);
+        _PyFreeList_Alloc(im);
         numfree--;
     }
     else {
@@ -2388,6 +2389,7 @@ instancemethod_dealloc(register PyMethod
     Py_XDECREF(im->im_self);
     Py_XDECREF(im->im_class);
     if (numfree < PyMethod_MAXFREELIST) {
+        _PyFreeList_Free(im);
         im->im_self = (PyObject *)free_list;
         free_list = im;
         numfree++;
diff -r 92003d9aae0e Objects/dictobject.c
--- a/Objects/dictobject.c	Tue Feb 26 12:37:07 2013 +0000
+++ b/Objects/dictobject.c	Fri Mar 22 12:01:53 2013 +0100
@@ -267,6 +267,7 @@ PyDict_New(void)
                if an empty but presized dict is added to freelist */
             INIT_NONZERO_DICT_SLOTS(mp);
         }
+        _PyFreeList_Alloc(mp);
         assert (mp->ma_used == 0);
         assert (mp->ma_table == mp->ma_smalltable);
         assert (mp->ma_mask == PyDict_MINSIZE - 1);
@@ -1012,8 +1013,10 @@ dict_dealloc(register PyDictObject *mp)
     }
     if (mp->ma_table != mp->ma_smalltable)
         PyMem_DEL(mp->ma_table);
-    if (numfree < PyDict_MAXFREELIST && Py_TYPE(mp) == &PyDict_Type)
+    if (numfree < PyDict_MAXFREELIST && Py_TYPE(mp) == &PyDict_Type) {
+        _PyFreeList_Free(mp);
         free_list[numfree++] = mp;
+    }
     else
         Py_TYPE(mp)->tp_free((PyObject *)mp);
     Py_TRASHCAN_SAFE_END(mp)
diff -r 92003d9aae0e Objects/floatobject.c
--- a/Objects/floatobject.c	Tue Feb 26 12:37:07 2013 +0000
+++ b/Objects/floatobject.c	Fri Mar 22 12:01:53 2013 +0100
@@ -150,6 +150,7 @@ PyFloat_FromDouble(double fval)
     op = free_list;
     free_list = (PyFloatObject *)Py_TYPE(op);
     PyObject_INIT(op, &PyFloat_Type);
+    _PyFreeList_Alloc(op);
     op->ob_fval = fval;
     return (PyObject *) op;
 }
@@ -240,6 +241,7 @@ static void
 float_dealloc(PyFloatObject *op)
 {
     if (PyFloat_CheckExact(op)) {
+        _PyFreeList_Alloc(op);
         Py_TYPE(op) = (struct _typeobject *)free_list;
         free_list = op;
     }
diff -r 92003d9aae0e Objects/frameobject.c
--- a/Objects/frameobject.c	Tue Feb 26 12:37:07 2013 +0000
+++ b/Objects/frameobject.c	Fri Mar 22 12:01:53 2013 +0100
@@ -478,6 +478,7 @@ frame_dealloc(PyFrameObject *f)
     if (co->co_zombieframe == NULL)
         co->co_zombieframe = f;
     else if (numfree < PyFrame_MAXFREELIST) {
+        _PyFreeList_Free(f);
         ++numfree;
         f->f_back = free_list;
         free_list = f;
@@ -699,6 +700,7 @@ PyFrame_New(PyThreadState *tstate, PyCod
                 }
             }
             _Py_NewReference((PyObject *)f);
+            _PyFreeList_Alloc(f);
         }
 
         f->f_code = code;
diff -r 92003d9aae0e Objects/intobject.c
--- a/Objects/intobject.c	Tue Feb 26 12:37:07 2013 +0000
+++ b/Objects/intobject.c	Fri Mar 22 12:01:53 2013 +0100
@@ -108,6 +108,7 @@ PyInt_FromLong(long ival)
     v = free_list;
     free_list = (PyIntObject *)Py_TYPE(v);
     PyObject_INIT(v, &PyInt_Type);
+    _PyFreeList_Alloc(v);
     v->ob_ival = ival;
     return (PyObject *) v;
 }
@@ -132,6 +133,7 @@ static void
 int_dealloc(PyIntObject *v)
 {
     if (PyInt_CheckExact(v)) {
+        _PyFreeList_Free(v);
         Py_TYPE(v) = (struct _typeobject *)free_list;
         free_list = v;
     }
@@ -1467,6 +1469,7 @@ int
         v = free_list;
         free_list = (PyIntObject *)Py_TYPE(v);
         PyObject_INIT(v, &PyInt_Type);
+        _PyFreeList_Alloc(v);
         v->ob_ival = ival;
         small_ints[ival + NSMALLNEGINTS] = v;
     }
diff -r 92003d9aae0e Objects/listobject.c
--- a/Objects/listobject.c	Tue Feb 26 12:37:07 2013 +0000
+++ b/Objects/listobject.c	Fri Mar 22 12:01:53 2013 +0100
@@ -134,6 +134,7 @@ PyList_New(Py_ssize_t size)
     if (numfree) {
         numfree--;
         op = free_list[numfree];
+        _PyFreeList_Alloc(op);
         _Py_NewReference((PyObject *)op);
 #ifdef SHOW_ALLOC_COUNT
         count_reuse++;
@@ -310,8 +311,10 @@ list_dealloc(PyListObject *op)
         }
         PyMem_FREE(op->ob_item);
     }
-    if (numfree < PyList_MAXFREELIST && PyList_CheckExact(op))
+    if (numfree < PyList_MAXFREELIST && PyList_CheckExact(op)) {
+        _PyFreeList_Alloc(op);
         free_list[numfree++] = op;
+    }
     else
         Py_TYPE(op)->tp_free((PyObject *)op);
     Py_TRASHCAN_SAFE_END(op)
diff -r 92003d9aae0e Objects/methodobject.c
--- a/Objects/methodobject.c	Tue Feb 26 12:37:07 2013 +0000
+++ b/Objects/methodobject.c	Fri Mar 22 12:01:53 2013 +0100
@@ -21,6 +21,7 @@ PyCFunction_NewEx(PyMethodDef *ml, PyObj
     if (op != NULL) {
         free_list = (PyCFunctionObject *)(op->m_self);
         PyObject_INIT(op, &PyCFunction_Type);
+        _PyFreeList_Alloc(op);
         numfree--;
     }
     else {
@@ -134,6 +135,7 @@ meth_dealloc(PyCFunctionObject *m)
     Py_XDECREF(m->m_self);
     Py_XDECREF(m->m_module);
     if (numfree < PyCFunction_MAXFREELIST) {
+        _PyFreeList_Alloc(m);
         m->m_self = (PyObject *)free_list;
         free_list = m;
         numfree++;
diff -r 92003d9aae0e Objects/object.c
--- a/Objects/object.c	Tue Feb 26 12:37:07 2013 +0000
+++ b/Objects/object.c	Fri Mar 22 12:01:53 2013 +0100
@@ -2335,27 +2335,6 @@ PyTypeObject *_Py_cobject_hack = &PyCObj
 Py_ssize_t (*_Py_abstract_hack)(PyObject *) = PyObject_Size;
 
 
-/* Python's malloc wrappers (see pymem.h) */
-
-void *
-PyMem_Malloc(size_t nbytes)
-{
-    return PyMem_MALLOC(nbytes);
-}
-
-void *
-PyMem_Realloc(void *p, size_t nbytes)
-{
-    return PyMem_REALLOC(p, nbytes);
-}
-
-void
-PyMem_Free(void *p)
-{
-    PyMem_FREE(p);
-}<commit_msg>fix python2.7_track_free_list.patch<commit_after>diff -r 92003d9aae0e Include/objimpl.h
--- a/Include/objimpl.h	Tue Feb 26 12:37:07 2013 +0000
+++ b/Include/objimpl.h	Fri Mar 22 12:01:53 2013 +0100
@@ -98,10 +98,15 @@ PyAPI_FUNC(void *) PyObject_Malloc(size_
 PyAPI_FUNC(void *) PyObject_Realloc(void *, size_t);
 PyAPI_FUNC(void) PyObject_Free(void *);
 
+PyAPI_FUNC(int) _PyFreeList_SetAllocators(
+    void (*alloc) (PyObject *),
+    void (*free) (PyObject *)
+);
 
-/* Macros */
-#ifdef WITH_PYMALLOC
-#ifdef PYMALLOC_DEBUG   /* WITH_PYMALLOC && PYMALLOC_DEBUG */
+PyAPI_FUNC(void) _PyFreeList_Alloc(void *);
+PyAPI_FUNC(void) _PyFreeList_Free(void *);
+
+#if defined(WITH_PYMALLOC) && defined(PYMALLOC_DEBUG)
 PyAPI_FUNC(void *) _PyObject_DebugMalloc(size_t nbytes);
 PyAPI_FUNC(void *) _PyObject_DebugRealloc(void *p, size_t nbytes);
 PyAPI_FUNC(void) _PyObject_DebugFree(void *p);
@@ -115,28 +120,14 @@ PyAPI_FUNC(void) _PyObject_DebugCheckAdd
 PyAPI_FUNC(void *) _PyMem_DebugMalloc(size_t nbytes);
 PyAPI_FUNC(void *) _PyMem_DebugRealloc(void *p, size_t nbytes);
 PyAPI_FUNC(void) _PyMem_DebugFree(void *p);
-#define PyObject_MALLOC         _PyObject_DebugMalloc
-#define PyObject_Malloc         _PyObject_DebugMalloc
-#define PyObject_REALLOC        _PyObject_DebugRealloc
-#define PyObject_Realloc        _PyObject_DebugRealloc
-#define PyObject_FREE           _PyObject_DebugFree
-#define PyObject_Free           _PyObject_DebugFree
+#endif
 
-#else   /* WITH_PYMALLOC && ! PYMALLOC_DEBUG */
+/* Macros */
 #define PyObject_MALLOC         PyObject_Malloc
 #define PyObject_REALLOC        PyObject_Realloc
 #define PyObject_FREE           PyObject_Free
-#endif
-
-#else   /* ! WITH_PYMALLOC */
-#define PyObject_MALLOC         PyMem_MALLOC
-#define PyObject_REALLOC        PyMem_REALLOC
-#define PyObject_FREE           PyMem_FREE
-
-#endif  /* WITH_PYMALLOC */
-
 #define PyObject_Del            PyObject_Free
-#define PyObject_DEL            PyObject_FREE
+#define PyObject_DEL            PyObject_Free
 
 /* for source compatibility with 2.2 */
 #define _PyObject_Del           PyObject_Free
diff -r 92003d9aae0e Include/pymem.h
--- a/Include/pymem.h	Tue Feb 26 12:37:07 2013 +0000
+++ b/Include/pymem.h	Fri Mar 22 12:01:53 2013 +0100
@@ -49,6 +49,24 @@ extern "C" {
    performed on failure (no exception is set, no warning is printed, etc).
 */
 
+#define PY_ALLOC_SYSTEM_API 's'   /* the system API (malloc, realloc, free) */
+#define PY_ALLOC_MEM_API 'm'      /* the PyMem_Malloc() API */
+#define PY_ALLOC_OBJECT_API 'o'   /* The PyObject_Malloc() API */
+
+PyAPI_FUNC(int) Py_GetAllocators(
+    char api,
+    void* (**malloc_p) (size_t),
+    void* (**realloc_p) (void*, size_t),
+    void (**free_p) (void*)
+    );
+
+PyAPI_FUNC(int) Py_SetAllocators(
+    char api,
+    void* (*malloc) (size_t),
+    void* (*realloc) (void*, size_t),
+    void (*free) (void*)
+    );
+
 PyAPI_FUNC(void *) PyMem_Malloc(size_t);
 PyAPI_FUNC(void *) PyMem_Realloc(void *, size_t);
 PyAPI_FUNC(void) PyMem_Free(void *);
@@ -57,13 +75,6 @@ PyAPI_FUNC(void) PyMem_Free(void *);
    no longer supported. They used to call PyErr_NoMemory() on failure. */
 
 /* Macros. */
-#ifdef PYMALLOC_DEBUG
-/* Redirect all memory operations to Python's debugging allocator. */
-#define PyMem_MALLOC		_PyMem_DebugMalloc
-#define PyMem_REALLOC		_PyMem_DebugRealloc
-#define PyMem_FREE		_PyMem_DebugFree
-
-#else	/* ! PYMALLOC_DEBUG */
 
 /* PyMem_MALLOC(0) means malloc(1). Some systems would return NULL
    for malloc(0), which would be treated as an error. Some platforms
@@ -71,13 +82,9 @@ PyAPI_FUNC(void) PyMem_Free(void *);
    pymalloc. To solve these problems, allocate an extra byte. */
 /* Returns NULL to indicate error if a negative size or size larger than
    Py_ssize_t can represent is supplied.  Helps prevents security holes. */
-#define PyMem_MALLOC(n)		((size_t)(n) > (size_t)PY_SSIZE_T_MAX ? NULL \
-				: malloc((n) ? (n) : 1))
-#define PyMem_REALLOC(p, n)	((size_t)(n) > (size_t)PY_SSIZE_T_MAX  ? NULL \
-				: realloc((p), (n) ? (n) : 1))
-#define PyMem_FREE		free
-
-#endif	/* PYMALLOC_DEBUG */
+#define PyMem_MALLOC(n)		PyMem_Malloc(n)
+#define PyMem_REALLOC(p, n)	PyMem_Realloc(p, n)
+#define PyMem_FREE(p)		PyMem_Free(p)
 
 /*
  * Type-oriented memory interface
diff -r 92003d9aae0e Lib/test/regrtest.py
--- a/Lib/test/regrtest.py	Tue Feb 26 12:37:07 2013 +0000
+++ b/Lib/test/regrtest.py	Fri Mar 22 12:01:53 2013 +0100
@@ -1,4 +1,8 @@
 #! /usr/bin/env python
+import tracemalloc
+tracemalloc.enable()
+top = tracemalloc.DisplayTop(5)
+top.start(2)
 
 """
 Usage:
diff -r 92003d9aae0e Objects/classobject.c
--- a/Objects/classobject.c	Tue Feb 26 12:37:07 2013 +0000
+++ b/Objects/classobject.c	Fri Mar 22 12:01:53 2013 +0100
@@ -2257,6 +2257,7 @@ PyMethod_New(PyObject *func, PyObject *s
     if (im != NULL) {
         free_list = (PyMethodObject *)(im->im_self);
         PyObject_INIT(im, &PyMethod_Type);
+        _PyFreeList_Alloc(im);
         numfree--;
     }
     else {
@@ -2388,6 +2389,7 @@ instancemethod_dealloc(register PyMethod
     Py_XDECREF(im->im_self);
     Py_XDECREF(im->im_class);
     if (numfree < PyMethod_MAXFREELIST) {
+        _PyFreeList_Free(im);
         im->im_self = (PyObject *)free_list;
         free_list = im;
         numfree++;
diff -r 92003d9aae0e Objects/dictobject.c
--- a/Objects/dictobject.c	Tue Feb 26 12:37:07 2013 +0000
+++ b/Objects/dictobject.c	Fri Mar 22 12:01:53 2013 +0100
@@ -267,6 +267,7 @@ PyDict_New(void)
                if an empty but presized dict is added to freelist */
             INIT_NONZERO_DICT_SLOTS(mp);
         }
+        _PyFreeList_Alloc(mp);
         assert (mp->ma_used == 0);
         assert (mp->ma_table == mp->ma_smalltable);
         assert (mp->ma_mask == PyDict_MINSIZE - 1);
@@ -1012,8 +1013,10 @@ dict_dealloc(register PyDictObject *mp)
     }
     if (mp->ma_table != mp->ma_smalltable)
         PyMem_DEL(mp->ma_table);
-    if (numfree < PyDict_MAXFREELIST && Py_TYPE(mp) == &PyDict_Type)
+    if (numfree < PyDict_MAXFREELIST && Py_TYPE(mp) == &PyDict_Type) {
+        _PyFreeList_Free(mp);
         free_list[numfree++] = mp;
+    }
     else
         Py_TYPE(mp)->tp_free((PyObject *)mp);
     Py_TRASHCAN_SAFE_END(mp)
diff -r 92003d9aae0e Objects/floatobject.c
--- a/Objects/floatobject.c	Tue Feb 26 12:37:07 2013 +0000
+++ b/Objects/floatobject.c	Fri Mar 22 12:01:53 2013 +0100
@@ -150,6 +150,7 @@ PyFloat_FromDouble(double fval)
     op = free_list;
     free_list = (PyFloatObject *)Py_TYPE(op);
     PyObject_INIT(op, &PyFloat_Type);
+    _PyFreeList_Alloc(op);
     op->ob_fval = fval;
     return (PyObject *) op;
 }
@@ -240,6 +241,7 @@ static void
 float_dealloc(PyFloatObject *op)
 {
     if (PyFloat_CheckExact(op)) {
+        _PyFreeList_Free(op);
         Py_TYPE(op) = (struct _typeobject *)free_list;
         free_list = op;
     }
diff -r 92003d9aae0e Objects/frameobject.c
--- a/Objects/frameobject.c	Tue Feb 26 12:37:07 2013 +0000
+++ b/Objects/frameobject.c	Fri Mar 22 12:01:53 2013 +0100
@@ -478,6 +478,7 @@ frame_dealloc(PyFrameObject *f)
     if (co->co_zombieframe == NULL)
         co->co_zombieframe = f;
     else if (numfree < PyFrame_MAXFREELIST) {
+        _PyFreeList_Free(f);
         ++numfree;
         f->f_back = free_list;
         free_list = f;
@@ -699,6 +700,7 @@ PyFrame_New(PyThreadState *tstate, PyCod
                 }
             }
             _Py_NewReference((PyObject *)f);
+            _PyFreeList_Alloc(f);
         }
 
         f->f_code = code;
diff -r 92003d9aae0e Objects/intobject.c
--- a/Objects/intobject.c	Tue Feb 26 12:37:07 2013 +0000
+++ b/Objects/intobject.c	Fri Mar 22 12:01:53 2013 +0100
@@ -108,6 +108,7 @@ PyInt_FromLong(long ival)
     v = free_list;
     free_list = (PyIntObject *)Py_TYPE(v);
     PyObject_INIT(v, &PyInt_Type);
+    _PyFreeList_Alloc(v);
     v->ob_ival = ival;
     return (PyObject *) v;
 }
@@ -132,6 +133,7 @@ static void
 int_dealloc(PyIntObject *v)
 {
     if (PyInt_CheckExact(v)) {
+        _PyFreeList_Free(v);
         Py_TYPE(v) = (struct _typeobject *)free_list;
         free_list = v;
     }
@@ -1467,6 +1469,7 @@ int
         v = free_list;
         free_list = (PyIntObject *)Py_TYPE(v);
         PyObject_INIT(v, &PyInt_Type);
+        _PyFreeList_Alloc(v);
         v->ob_ival = ival;
         small_ints[ival + NSMALLNEGINTS] = v;
     }
diff -r 92003d9aae0e Objects/listobject.c
--- a/Objects/listobject.c	Tue Feb 26 12:37:07 2013 +0000
+++ b/Objects/listobject.c	Fri Mar 22 12:01:53 2013 +0100
@@ -134,6 +134,7 @@ PyList_New(Py_ssize_t size)
     if (numfree) {
         numfree--;
         op = free_list[numfree];
+        _PyFreeList_Alloc(op);
         _Py_NewReference((PyObject *)op);
 #ifdef SHOW_ALLOC_COUNT
         count_reuse++;
@@ -310,8 +311,10 @@ list_dealloc(PyListObject *op)
         }
         PyMem_FREE(op->ob_item);
     }
-    if (numfree < PyList_MAXFREELIST && PyList_CheckExact(op))
+    if (numfree < PyList_MAXFREELIST && PyList_CheckExact(op)) {
+        _PyFreeList_Free(op);
         free_list[numfree++] = op;
+    }
     else
         Py_TYPE(op)->tp_free((PyObject *)op);
     Py_TRASHCAN_SAFE_END(op)
diff -r 92003d9aae0e Objects/methodobject.c
--- a/Objects/methodobject.c	Tue Feb 26 12:37:07 2013 +0000
+++ b/Objects/methodobject.c	Fri Mar 22 12:01:53 2013 +0100
@@ -21,6 +21,7 @@ PyCFunction_NewEx(PyMethodDef *ml, PyObj
     if (op != NULL) {
         free_list = (PyCFunctionObject *)(op->m_self);
         PyObject_INIT(op, &PyCFunction_Type);
+        _PyFreeList_Alloc(op);
         numfree--;
     }
     else {
@@ -134,6 +135,7 @@ meth_dealloc(PyCFunctionObject *m)
     Py_XDECREF(m->m_self);
     Py_XDECREF(m->m_module);
     if (numfree < PyCFunction_MAXFREELIST) {
+        _PyFreeList_Free(m);
         m->m_self = (PyObject *)free_list;
         free_list = m;
         numfree++;
diff -r 92003d9aae0e Objects/object.c
--- a/Objects/object.c	Tue Feb 26 12:37:07 2013 +0000
+++ b/Objects/object.c	Fri Mar 22 12:01:53 2013 +0100
@@ -2335,27 +2335,6 @@ PyTypeObject *_Py_cobject_hack = &PyCObj
 Py_ssize_t (*_Py_abstract_hack)(PyObject *) = PyObject_Size;
 
 
-/* Python's malloc wrappers (see pymem.h) */
-
-void *
-PyMem_Malloc(size_t nbytes)
-{
-    return PyMem_MALLOC(nbytes);
-}
-
-void *
-PyMem_Realloc(void *p, size_t nbytes)
-{
-    return PyMem_REALLOC(p, nbytes);
-}
-
-void
-PyMem_Free(void *p)
-{
-    PyMem_FREE(p);
-}
{'fraction_non_alphanumeric': 0.14096704354101516, 'fraction_numerical': 0.05994707721914842, 'mean_word_length': 3.216227180527383, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 57, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7126631', 'n_tokens_mistral': 8953, 'n_tokens_neox': 7999, 'n_words': 1637}