Skip to content

Is it possible to share the same #[pyclass] instance as argument to python function in rust? #3010

Answered by adamreichold
sun-rs asked this question in Questions
Discussion options

You must be logged in to vote

on_event will want access to something like &PyAny as it will not be able to handle the Rust type Context. So maybe something like

    pub fn run_backtest(&self, ctx: &PyCell<Context>) {
        for i in 0..10000 {
            ctx.borrow_mut().add();
            ctx.userdef.call_method1(intern!(ctx.py(), "on_event"), ctx);
        }
    }

?

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@sun-rs
Comment options

@adamreichold
Comment options

Answer selected by sun-rs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants