Open alecandido opened 1 year ago
Here's another take on this: https://towardsdatascience.com/nine-rules-for-writing-python-extensions-in-rust-d35ea3a4ec29.
Here's another take on this: towardsdatascience.com/nine-rules-for-writing-python-extensions-in-rust-d35ea3a4ec29.
I need some time to digest. If you already did (or you will do before), can you turn the content of the article in further points in the OP? (or a separate message if you like more)
I was more a reminder for myself to read it :smiley:. I also saw it's an article from 2022, so I probably linked it before (I vaguely recall doing that).
With other burdens out of the way, I can now put this in the priority list. Will also need some time to digest everything above but will dive into the actual changes soon.
This issue is pretty old, and PyO3 is quickly evolving. Please, check the newly available features before attempting any implementation :)
One example that showcases how to simplify the implementation is commit 696ad6ffbc4a7febbde44334a8d7905b50e7a0b8, which uses some new features of PyO3 that allows to remove the corresponding Python wrapper method (done in commit 0d9876fb5bc857beddf4eb4eec323e4cf037d509).
Thanks both! I will have a look.
There are a bunch of items that can be improved in the Python interface, eventually leading to less code to maintain and better DX for
pineappl_py
consumers:pineappl_py/pineappl
, since at this point we have enough tools in PyO3 ecosystem (pyo3
,rust-numpy
, and extras, e.g. logging, if ever any of these will be needed) to provide a Python native experience without a dedicated layer (we can work with numpy arrays, add static/classmethods, and getters and setters with properties)pineappl
crate with PyO3 declarative macros; this is rather ugly, because then we might want to do the same for C bindings, and further ones in case we will ever support new languages (so scaling the number of macros with the languages supported); so either we find a native way to generate code using PyO3 macros, or we should write our own macros to generate the code corresponding to repeated patterns in current content ofpineappl_py/src
anyhow
feature, since @cschwan already started introducinganyhow
in mainpineappl
crate