Skip to content

Commit

Permalink
update to PyO3 0.21 final (#71)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidhewitt committed Mar 28, 2024
1 parent 2372599 commit cbf2e30
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 28 deletions.
12 changes: 6 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ num-bigint = "0.4.4"
num-traits = "0.2.16"
ahash = "0.8.0"
smallvec = "1.11.0"
pyo3 = { version = "0.21.0-beta.0", default-features=false, features = ["num-bigint"], optional = true }
pyo3 = { version = "0.21.0", default-features=false, features = ["num-bigint"], optional = true }
lexical-parse-float = { version = "0.8.5", features = ["format"] }

[features]
Expand All @@ -26,7 +26,7 @@ bencher = "0.1.5"
paste = "1.0.7"
serde_json = {version = "1.0.87", features = ["preserve_order", "arbitrary_precision", "float_roundtrip"]}
serde = "1.0.147"
pyo3 = { version = "0.21.0-beta.0", default-features=false, features = ["num-bigint", "auto-initialize"] }
pyo3 = { version = "0.21.0", default-features=false, features = ["num-bigint", "auto-initialize"] }
codspeed-bencher-compat = "2.3.1"

[profile.bench]
Expand Down
32 changes: 12 additions & 20 deletions src/python.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,28 +88,20 @@ impl<'j> PythonParser<'j> {
Ok(StringCache::get_value(py, s.as_str()).into_any())
}
Peek::Array => {
let opt_peek_first = match self.parser.array_first() {
Ok(p) => p,
Err(e) => {
if self._allow_partial_err(&e) {
None
} else {
return Err(e);
}
}
let peek_first = match self.parser.array_first() {
Ok(Some(peek)) => peek,
Err(e) if !self._allow_partial_err(&e) => return Err(e),
Ok(None) | Err(_) => return Ok(PyList::empty_bound(py).into_any()),
};
let list = if let Some(peek_first) = opt_peek_first {
let mut vec: SmallVec<[Bound<'_, PyAny>; 8]> = SmallVec::with_capacity(8);
if let Err(e) = self._parse_array::<StringCache>(py, peek_first, &mut vec) {
if !self._allow_partial_err(&e) {
return Err(e);
}

let mut vec: SmallVec<[Bound<'_, PyAny>; 8]> = SmallVec::with_capacity(8);
if let Err(e) = self._parse_array::<StringCache>(py, peek_first, &mut vec) {
if !self._allow_partial_err(&e) {
return Err(e);
}
PyList::new_bound(py, vec)
} else {
PyList::empty_bound(py)
};
Ok(list.into_any())
}

Ok(PyList::new_bound(py, vec).into_any())
}
Peek::Object => {
let dict = PyDict::new_bound(py);
Expand Down

0 comments on commit cbf2e30

Please sign in to comment.