LD_DEBUG: ImportModuleLevelObject isn't loaded in >3.9 but only with miniconda installs?

Hello, I had a question about when exactly PyImport_ImportModuleLevelObject is used. My impression was that, except for frozen modules, it was used any time a module was imported, at least with default finders and loaders. But when I use the libpython.so installed by miniconda for >3.9 versions, I don’t see it loaded in LD_DEBUG=all logs

For this experiment, I was running in linux and using miniconda (modify /miniconda path if no root access).:

wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash ./Miniconda3-latest-Linux-x86_64.sh -b -p /miniconda
export PATH=/miniconda/bin:$PATH
eval "$(/miniconda/bin/conda shell.bash hook)"
conda create -y -n py39 python=3.9
conda create -y -n py310 python=3.10
conda activate py39

My intent was to simply do touch foo.py; LD_DEBUG=all python3 -c 'import foo' and see symbol=PyImport_ImportModuleLevelObject output in the logs. But $CONDA_PREFIX/bin/python3 is statically compiled, and thus LD_DEBUG would have no effect. To workaround this, I made a little helper c script, run_py.c, which simply loads the libpython.so shared library from my conda’s python install and calls Py_BytesMain:

#define _GNU_SOURCE
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <dlfcn.h>
#include <link.h>

int main(int argc, char *argv[]){
    printf("START: MY EXEC\n");
    // Make sure to modify dlopen path and recompile for each conda environment!
    void *handle = dlopen("<path-to-conda-env>/lib/libpython3.<minor-python>.so.1.0", RTLD_LAZY|RTLD_GLOBAL);
    if (!handle) {
        fprintf(stderr, "%s\n", dlerror());
        return 1;

    int (*py_main)(int, char **);
    py_main = (int (*)(int, char **)) dlsym(handle, "Py_BytesMain");
    (*py_main)(argc, argv);

Compiling run_py.c and then running it in a conda environment looks like:

gcc -o my_exec my_exec.c -lc -ldl && LD_DEBUG=all ./my_exec python3 -c 'import foo'

When I “conda activate py3.9” and and modify run_py.c to point to its libpython.so path, I see the “symbol=PyImport_ImportModuleLevelObject” logs from LD_DEBUG i expected. But when I do the same thing with “conda activate py3.10” (and >python3.10), I don’t.

Both cases complete and successfully import foo (I put print statements in to be sure). Idk why the change in behavior. I have also ran this experiment successfully with the python3.10 installed on my system, and ran it unsuccessfully with python3.10 installed by miniconda, so it appears something specific to python3.9+ miniconda installed builds.

Any ideas what might be causing this?