Patch #1953
I implemented the function sys._compact_freelists() and C API functions PyInt_/PyFloat_CompactFreeList() to compact the pre-allocated blocks of ints and floats. They allow the user to reduce the memory usage of a Python process that deals with lots of numbers.
The patch also renames sys._cleartypecache to sys._clear_type_cache
diff --git a/Doc/c-api/float.rst b/Doc/c-api/float.rst
index 505c19e..bb4f74a 100644
--- a/Doc/c-api/float.rst
+++ b/Doc/c-api/float.rst
@@ -84,3 +84,12 @@
Return the minimum normalized positive float *DBL_MIN* as C :ctype:`double`.
.. versionadded:: 2.6
+
+
+.. cfunction:: void PyFloat_CompactFreeList(size_t *bc, size_t *bf, size_t *sum)
+
+ Compact the float free list. *bc* is the number of allocated blocks before
+ blocks are freed, *bf* is the number of freed blocks and *sum* is the number
+ of remaining objects in the blocks.
+
+ .. versionadded:: 2.6
diff --git a/Doc/c-api/int.rst b/Doc/c-api/int.rst
index 526083b..94bf380 100644
--- a/Doc/c-api/int.rst
+++ b/Doc/c-api/int.rst
@@ -120,3 +120,12 @@
Return the system's idea of the largest integer it can handle
(:const:`LONG_MAX`, as defined in the system header files).
+
+
+.. cfunction:: void PyInt_CompactFreeList(size_t *bc, size_t *bf, size_t *sum)
+
+ Compact the integer free list. *bc* is the number of allocated blocks before
+ blocks are freed, *bf* is the number of freed blocks and *sum* is the number
+ of remaining objects in the blocks.
+
+ .. versionadded:: 2.6