On second thoughts, maybe we should refactor this. Currently `prun` is used both as a magic command, and as a function to be called by other code, which makes it somewhat confusing. Maybe the core should be pulled out into another function, so that `prun` is just for the magic command. Going by your other changes, the new function could be called `_run_with_profiler`.