If you’re more comfortable coding SQL than Python, it might be worth a try.
The handles that Gramps creates are merely a combination of a timestamp and a random number, which you can achieve with SQL functions (see discussion here).
But the handles you create need not be cryptic, just unique. If you had a sufficiently long list of unique items (e.g. words from a dictionary, used singly or in random combinations, somewhat like what3words.com does for locations), I imagine those would serve just as well, if you took care to use each word or combination only once.
Import your results to a new Gramps tree and run the various tools and utilities for verifying the data.