We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
Py_CompileString
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When using py.run, pyo3 will always compile the code (https://pyo3.rs/main/doc/src/pyo3/marker.rs#653).
py.run
I'd like to see ffi::Py_CompileString exposed in the API so I can compile once, and py.run_code_object multiple times after that.
ffi::Py_CompileString
py.run_code_object
The text was updated successfully, but these errors were encountered:
Seems like a reasonable addition by extending our PyCode type.
PyCode
Sorry, something went wrong.
I'd be interested in working on this if it hasn't been picked up yet. Could you explain more about extending PyCode?
I'm also curious if the following could be a possible approach:
(1) Create 2 new methods:
pub fn compile_code_string(self, code_str: &CStr, start: c_int) -> Bound<'py, PyCode> {...} pub fn run_code_object(self, code_obj: &Bound<'py, PyCode>, globals: Option<&Bound<'py, PyDict>>, locals: Option<&Bound<'py, PyDict>>) -> PyResult<Bound<'py, PyAny>> {...}
(2) Modify run_code so that it calls compile_code_string followed by run_code_object.
run_code
compile_code_string
run_code_object
(3) Document the methods as part of the public API.
I'm still new to the codebase, so this is just an initial thought.
Yeah something like that. I'd just call them compile and run though.
compile_string
Successfully merging a pull request may close this issue.
When using
py.run
, pyo3 will always compile the code (https://pyo3.rs/main/doc/src/pyo3/marker.rs#653).I'd like to see
ffi::Py_CompileString
exposed in the API so I can compile once, andpy.run_code_object
multiple times after that.The text was updated successfully, but these errors were encountered: