Glyphs doesn't clear local scope after running script?

Today I learned that Glyphs does not clear the local scope after running scripts and macros. What’s the best way to clear the scope, perhaps with some code at the beginning of a script? I’m running into some problems where Script B is able to call a function from Script A simply because Script A was run recently.

The scope is the same. I’m not sure if I can change that.

I have no idea about the internals of how a Python environment is embedded inside of Glyphs, but I can imagine it might not be an easy thing to change.

But if things are being left behind every time I run a script in Glyphs, does that amount to an ever-increasing memory leak until I restart the app? I don’t know much about garbage collection in Python, but I don’t think any variables that are still bound to the local scope would be cleaned up.

I’m not sure if this is a big problem that needs to be fixed, but it sure causes some occasional headaches if I have to account for other scripts unrelated to the one I’m debugging.