Skip to content

Commit d2e33d9

Browse files
committed
intro: 05-gil
Using PyO3 native types, handling the GIL
1 parent 756ef43 commit d2e33d9

File tree

1 file changed

+6
-3
lines changed
  • exercises/01_intro/05_gil/src

1 file changed

+6
-3
lines changed

exercises/01_intro/05_gil/src/lib.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1-
use pyo3::prelude::*;
1+
use pyo3::{prelude::*, types::PyList};
22

33
#[pyfunction]
44
// TODO: Use `PyList` instead of `Vec<u64>` as the input type. Panic on errors, for now.
55
// You might find this useful: https://pyo3.rs/v0.22.0/conversions/traits#extract-and-the-frompyobject-trait
6-
fn print_number_list() {
7-
todo!()
6+
fn print_number_list(numbers: Bound<'_, PyList>) {
7+
for num_obj in numbers {
8+
let num: u64 = num_obj.extract().unwrap();
9+
println!("{num}")
10+
}
811
}
912

1013
#[pymodule]

0 commit comments

Comments
 (0)