Skip to content

Commit 3913171

Browse files
committed
use GILOnceCell::import
1 parent 1fd7bb5 commit 3913171

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

src/random.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -82,16 +82,8 @@ unsafe impl PyTypeInfo for PyBitGenerator {
8282
fn type_object_raw<'py>(py: Python<'py>) -> *mut ffi::PyTypeObject {
8383
static CLS: GILOnceCell<Py<PyType>> = GILOnceCell::new();
8484
let cls = CLS
85-
.get_or_try_init::<_, PyErr>(py, || {
86-
Ok(py
87-
.import("numpy.random")?
88-
.getattr("BitGenerator")?
89-
.downcast_into::<PyType>()?
90-
.unbind())
91-
})
92-
.expect("Failed to get BitGenerator type object")
93-
.clone_ref(py)
94-
.into_bound(py);
85+
.import(py, "numpy.random", "BitGenerator")
86+
.expect("Failed to get BitGenerator type object");
9587
cls.as_type_ptr()
9688
}
9789
}

0 commit comments

Comments
 (0)