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() {
|
2022-07-19 17:34:23 +00:00
|
|
|
Python::with_gil(|py| {
|
|
|
|
const LEN: usize = 10_000_000;
|
2024-02-10 12:59:55 +00:00
|
|
|
let dict = (0..LEN as u64).map(|i| (i, i * 2)).into_py_dict_bound(py);
|
2022-07-19 17:34:23 +00:00
|
|
|
let mut sum = 0;
|
2023-07-14 09:28:17 +00:00
|
|
|
for (k, _v) in dict {
|
2022-07-19 17:34:23 +00:00
|
|
|
let i: u64 = k.extract().unwrap();
|
|
|
|
sum += i;
|
|
|
|
}
|
|
|
|
assert_eq!(sum, 49_999_995_000_000);
|
|
|
|
});
|
2018-11-18 03:13:20 +00:00
|
|
|
}
|