Closed EricLBuehler closed 3 months ago
Awesome work by the way!
Pinging @ArthurZucker as this might be useful. Do you want this to be an individual repo that you can use?
This basically would make it possible to auto-generate the python __dir__
and in the future __dict__
that is used by the python debugger.
Additionally we could integrate your display code as a derive macro so that anyone who want to have a quick implementation of it can use it.
Maybe we can check if we can use: https://pyo3.rs/v0.21.2/features.html#multiple-pymethods ?
I added this feature.
This basically would make it possible to auto-generate the python dir and in the future dict that is used by the python debugger.
I think the __dict__
would end up being very similar to the implementation of the Display derive macro in tokenizers
, so that can be done quickly.
So just played further with it! And really like it! Could be really good to have a skip method. I think that it's quite a common use case to not want to expose the rust implementation, it would also make it easier to check by iteration. Let's do this in a follow up PR within its own repo :)
Thanks a lot!
Ok, great! I'll make a separate repo. Should I close this PR and reopen to use the new crate?
So, let's publish a new crate on crates.io and link it in this PR if that's ok?
I published a v0.1.0 version of that crate: https://docs.rs/pyo3_special_method_derive/
Here is the Github: https://github.com/EricLBuehler/pyo3-special-method-derive
This PR uses a proc macro to retrieve the field names for the
__dir__
method.Currently, this will show all field names regardless of visibility or accessibility from Python. Perhaps we should change this such that only methods which are marked somehow as accessible from Python can be exposed?