pyo3/tests/test_dict_iter.rs
2018-11-21 16:00:26 +09:00

18 lines
424 B
Rust

extern crate pyo3;
use pyo3::{prelude::*, types::IntoPyDict};
#[test]
fn iter_dict_nosegv() {
let gil = Python::acquire_gil();
let py = gil.python();
const LEN: usize = 10_000_000;
let dict = (0..LEN as u64).map(|i| (i, i * 2)).into_py_dict(py);
let mut sum = 0;
for (k, _v) in dict.iter() {
let i: u64 = k.extract().unwrap();
sum += i;
}
assert_eq!(sum, 49999995000000);
}