It also happened to me when the app or the script running try to access a restricted part of the memory or when there is not enough RAM
Since your script does not crash on my ipad pro 2017 (4GBs of RAM) too, i believe it's the second option
Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.