That would work well only if there are no pointers in the load result, which sometimes (if rarely) happens without planning in C or C++ code, but almost never -- or actually never -- happens with Python code.
You can have all the pointers you want. The way my code works is it uses MAP_FIXED so that memory is always allocated to the same addresses. Even if you have ASLR it will be the same every time.
The issue is mainly stack-allocated memory. For example, our `model` object here needed to be allocated on the heap, rather than being declared as an automatic variable. Since automatic objects is really an optimization unique to low-level languages like C++, I doubt that's going to be an issue for something like Python, where everything is probably a heap object.
Oh! Also be careful about .data objects (i.e. static variables). Those could prove problematic too. Although my code could easily be updated to memcpy() the memory between _etext and _end into the file.
Or am I missing something?