The simple solution is this. Rather than using
y = py.mymodule.myfun(x);
Instead, use
mymod = py.importlib.import_module('mymodule');
py.importlib.reload(mymod);
y = mymod.myfun(x);
This (apparently) ensures you will be calling the latest (saved) version of mymodule whenever you call myfun - at least while running Matlab version 2024b with Python version 3.12.
I am answering my own question because I have read through plenty of threads (see below for some of them) and not seen this relatively simple solution anywhere. I hope it can help others and save them some time.
Some related threads: