2019-02-01 13:01:18 +00:00
|
|
|
use pyo3::prelude::*;
|
|
|
|
use pyo3::types::IntoPyDict;
|
2018-11-18 03:13:20 +00:00
|
|
|
|
|
|
|
#[test]
|
2022-06-08 04:59:18 +00:00
|
|
|
#[cfg_attr(target_arch = "wasm32", ignore)] // Not sure why this fails.
|
2018-11-18 03:13:20 +00:00
|
|
|
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;
|
|
|
|
}
|
2019-08-17 12:10:35 +00:00
|
|
|
assert_eq!(sum, 49_999_995_000_000);
|
2018-11-18 03:13:20 +00:00
|
|
|
}
|