-
Notifications
You must be signed in to change notification settings - Fork 124
support 3.13t free-threaded python #471
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
2b364d3
28d1edd
94348d1
2b9ccf2
ee9066c
177927c
cc109bf
e58c0af
e4ca231
74bc5dd
5f4c90a
4ee024a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,16 +3,15 @@ | |
//! [ascii]: https://numpy.org/doc/stable/reference/c-api/dtype.html#c.NPY_STRING | ||
//! [ucs4]: https://numpy.org/doc/stable/reference/c-api/dtype.html#c.NPY_UNICODE | ||
|
||
use std::cell::RefCell; | ||
use std::collections::hash_map::Entry; | ||
use std::fmt; | ||
use std::mem::size_of; | ||
use std::os::raw::c_char; | ||
use std::str; | ||
use std::sync::Mutex; | ||
|
||
use pyo3::{ | ||
ffi::{Py_UCS1, Py_UCS4}, | ||
sync::GILProtected, | ||
Bound, Py, Python, | ||
}; | ||
use rustc_hash::FxHashMap; | ||
|
@@ -160,14 +159,13 @@ unsafe impl<const N: usize> Element for PyFixedUnicode<N> { | |
} | ||
|
||
struct TypeDescriptors { | ||
#[allow(clippy::type_complexity)] | ||
dtypes: GILProtected<RefCell<Option<FxHashMap<usize, Py<PyArrayDescr>>>>>, | ||
dtypes: Mutex<Option<FxHashMap<usize, Py<PyArrayDescr>>>>, | ||
} | ||
|
||
impl TypeDescriptors { | ||
const fn new() -> Self { | ||
Self { | ||
dtypes: GILProtected::new(RefCell::new(None)), | ||
dtypes: Mutex::new(None), | ||
} | ||
} | ||
|
||
|
@@ -180,7 +178,8 @@ impl TypeDescriptors { | |
byteorder: c_char, | ||
size: usize, | ||
) -> Bound<'py, PyArrayDescr> { | ||
let mut dtypes = self.dtypes.get(py).borrow_mut(); | ||
// FIXME probably a deadlock risk here due to the GIL? Might need MutexExt trait in PyO3 | ||
let mut dtypes = self.dtypes.lock().expect("dtype cache poisoned"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choice to use Given that writes to this should be infrequent (it's a global cache, as far as I can tell), I also wonder if ... in which case I want There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So I guess I should finally write |
||
|
||
let dtype = match dtypes.get_or_insert_with(Default::default).entry(size) { | ||
Entry::Occupied(entry) => entry.into_mut(), | ||
|
Uh oh!
There was an error while loading. Please reload this page.