Finding out if a python binary has been compiled with or without pymalloc

Skip Montanaro skip at pobox.com
Tue Dec 11 16:56:07 CET 2001


    Rémi> I'd like to know if there is a way to find out if a python binary
    Rémi> distribution has been compiled with or without pymalloc.  My
    Rémi> website hosting machine has python2.1 installed on it, but I don't
    Rémi> know where this distribution comes from. I only have access to the
    Rémi> python2.1 binary, and I'd like to check if it uses pymalloc or
    Rémi> not.

The strings command is a crude, but often effective way to search for
symbols in an executable.  My normal Python executable is compiled with
threads and without pymalloc:

    % strings -a /usr/local/bin/python | egrep -i malloc | sort -u
    malloc
    malloc@@GLIBC_2.0
    PyMem_Malloc
    _PyObject_GC_Malloc
    PyObject_Malloc

I also have a without-threads with-pymalloc version, however:

    % strings -a python | egrep -i malloc | sort -u
    malloc
    malloc@@GLIBC_2.0
    malloc_hook
    _PyCore_ObjectMalloc
    _PyCore_ObjectMalloc_FetchHooks
    _PyCore_ObjectMalloc_SetHooks
    PyMem_Malloc
    _PyObject_GC_Malloc
    PyObject_Malloc

Note the extra *ObjectMalloc* symbols.

This is on a recent Linux system using gcc and neither executable was
stripped.  YMMV.

-- 
Skip Montanaro (skip at pobox.com - http://www.mojam.com/)




More information about the Python-list mailing list