mirror of
https://github.com/RustPython/Parser.git
synced 2025-07-08 05:35:22 +00:00
Add pyo3 support:
This commit is contained in:
parent
6b90a006a1
commit
4119a9084b
4 changed files with 5 additions and 3 deletions
|
@ -30,6 +30,7 @@ itertools = "0.10.3"
|
|||
is-macro = "0.2.2"
|
||||
log = "0.4.16"
|
||||
num-complex = "0.4.0"
|
||||
num-bigint = "0.4.3"
|
||||
num-traits = "0.2"
|
||||
pyo3 = { version = "0.18.3" }
|
||||
malachite-bigint = { version = "0.1.5", git = "https://github.com/qingshi163/malachite-bigint.git" }
|
||||
|
|
|
@ -15,7 +15,7 @@ fold = []
|
|||
unparse = ["rustpython-literal"]
|
||||
visitor = []
|
||||
all-nodes-with-ranges = []
|
||||
pyo3 = ["dep:pyo3", "num-complex", "once_cell"]
|
||||
pyo3 = ["dep:pyo3", "num-complex", "once_cell", "num-bigint", "malachite-bigint/num-bigint"]
|
||||
|
||||
# This feature is experimental
|
||||
# It reimplements AST types, but currently both slower than python AST types and limited to use in other API
|
||||
|
@ -26,6 +26,7 @@ rustpython-parser-core = { workspace = true }
|
|||
rustpython-literal = { workspace = true, optional = true }
|
||||
|
||||
is-macro = { workspace = true }
|
||||
num-bigint = { workspace = true, optional = true }
|
||||
static_assertions = "1.1.0"
|
||||
num-complex = { workspace = true, optional = true }
|
||||
once_cell = { workspace = true, optional = true }
|
||||
|
|
|
@ -90,7 +90,7 @@ impl ToPyo3Ast for crate::Constant {
|
|||
crate::Constant::Bool(bool) => bool.to_object(py),
|
||||
crate::Constant::Str(string) => string.to_object(py),
|
||||
crate::Constant::Bytes(bytes) => PyBytes::new(py, bytes).into(),
|
||||
crate::Constant::Int(int) => int.to_object(py),
|
||||
crate::Constant::Int(int) => num_bigint::BigInt::from(int.clone()).to_object(py),
|
||||
crate::Constant::Tuple(elts) => {
|
||||
let elts: PyResult<Vec<_>> = elts.iter().map(|c| c.to_pyo3_ast(py)).collect();
|
||||
PyTuple::new(py, elts?).into()
|
||||
|
|
|
@ -67,7 +67,7 @@ impl ToPyo3Wrapper for crate::Constant {
|
|||
crate::Constant::Bool(bool) => bool.to_object(py),
|
||||
crate::Constant::Str(string) => string.to_object(py),
|
||||
crate::Constant::Bytes(bytes) => PyBytes::new(py, bytes).into(),
|
||||
crate::Constant::Int(int) => int.to_object(py),
|
||||
crate::Constant::Int(int) => num_bigint::BigInt::from(int.clone()).to_object(py),
|
||||
crate::Constant::Tuple(elts) => {
|
||||
let elts: PyResult<Vec<_>> = elts.iter().map(|c| c.to_pyo3_wrapper(py)).collect();
|
||||
PyTuple::new(py, elts?).into()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue