I frequently find myself accelerating iterative Python code by using PyO3. I usually use Jupyter Notebooks for developing/testing algorithms, and it's been really great. The only thing I struggle with is debugging logic errors in my Rust code.
Usually I'd try to put in some Python
print() or Rust
dbg!() to understand what's going on. However, some part of the Jupyter->PyO3 stack seems to eat whatever I try to print on the Rust side. It's not visible in the Jupyter notebook, and neither does it show up on the CLI where I started Jupyter.
I'd be grateful for any tips on how to get my debug prints back, as well as any other cool tricks you might know for debugging PyO3 modules from inside a Jupyter notebook.
Edit: Turns out, Jupyter actually gets stdout/stderr from the rust side, except it silently rate limits the output and gets hung up if there's too much output too fast. I reduced the amount of logging to a handful of lines and now I can read it in the notebook.