use std::cell::RefCell;
use std::collections::HashMap;
use pyo3::{Py, PyAny};
thread_local! {
static OPAQUE_BUS: RefCell<HashMap<&'static str, Py<PyAny>>> = RefCell::new(HashMap::new());
}
pub fn store_opaque(type_name: &'static str, obj: Py<PyAny>) {
OPAQUE_BUS.with(|bus| {
bus.borrow_mut().insert(type_name, obj);
});
}
pub fn take_opaque(type_name: &'static str) -> Option<Py<PyAny>> {
OPAQUE_BUS.with(|bus| bus.borrow_mut().remove(type_name))
}