With eBPF you can easily trace function calls in a python program:
sudo pythonflow-bpfcc <pidof-python-process>