Two approaches are described. The first makes almost no changes
to Python; but uses the GC version of malloc and
free. [reference counting is left intact] The second approach
removes the reference-counting code, and requires patches to
about 10 of the source files. This is a more dangerous option,
but should perform better.

Building the GC library

Build it in /usr/src/gc

If you're on linux, version 4.10 of the gc library may not build; a
manual include of 'sigcontext.h' will do the trick. Near the top of
"gc/os_dep.c":

The explicit include path is important! Don't use "-I/usr/src/gc",
because the gc library also uses a 'config.h' file, which you don't
want to include by mistake.
run configure.
Now, run 'make', but include the gc library in the definition of the
symbol 'LIBS':

make LIBS="-lieee -ldl /usr/src/gc/gc.a"
^^^^^^^^^^^
[these are taken from the LIBS definition in a normal Makefile
yours may be different]
$ mv python gc-python

That should do it!

Building the no-refcnt version

This is a patched version of Python-1.5.1 that removes reference
counting altogether. Start with a virgin copy of 1.5.1.