Merge #2593
2593: docs: mention PyBuffer r=adamreichold a=davidhewitt Uses PEP 688 `types.Buffer` to describe `PyBuffer<T>` in the conversion tables. Will leave as draft until PEP 688 is finalised. Closes #954 Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com> Co-authored-by: Adam Reichold <adam.reichold@t-online.de>
This commit is contained in:
commit
633b592ed5
|
@ -33,6 +33,7 @@ The table below contains the Python type and the corresponding function argument
|
|||
| `datetime.time` | - | `&PyTime` |
|
||||
| `datetime.tzinfo` | - | `&PyTzInfo` |
|
||||
| `datetime.timedelta` | - | `&PyDelta` |
|
||||
| `collections.abc.Buffer` | - | `PyBuffer<T>` |
|
||||
| `typing.Optional[T]` | `Option<T>` | - |
|
||||
| `typing.Sequence[T]` | `Vec<T>` | `&PySequence` |
|
||||
| `typing.Mapping[K, V]` | `HashMap<K, V>`, `BTreeMap<K, V>`, `hashbrown::HashMap<K, V>`[^2], `indexmap::IndexMap<K, V>`[^3] | `&PyMapping` |
|
||||
|
|
|
@ -452,6 +452,9 @@ def set_minimal_package_versions(session: nox.Session):
|
|||
"cxx": "1.0.92",
|
||||
"cxxbridge-macro": "1.0.92",
|
||||
"cxx-build": "1.0.92",
|
||||
"web-sys": "0.3.61",
|
||||
"js-sys": "0.3.61",
|
||||
"wasm-bindgen": "0.2.84",
|
||||
"syn": "1.0.109",
|
||||
}
|
||||
|
||||
|
|
|
@ -189,7 +189,7 @@ impl<'source, T: Element> FromPyObject<'source> for PyBuffer<T> {
|
|||
}
|
||||
|
||||
impl<T: Element> PyBuffer<T> {
|
||||
/// Get the underlying buffer from the specified python object.
|
||||
/// Gets the underlying buffer from the specified python object.
|
||||
pub fn get(obj: &PyAny) -> PyResult<PyBuffer<T>> {
|
||||
// TODO: use nightly API Box::new_uninit() once stable
|
||||
let mut buf = Box::new(mem::MaybeUninit::uninit());
|
||||
|
@ -616,8 +616,10 @@ impl<T: Element> PyBuffer<T> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Release the buffer object, freeing the reference to the Python object
|
||||
/// Releases the buffer object, freeing the reference to the Python object
|
||||
/// which owns the buffer.
|
||||
///
|
||||
/// This will automatically be called on drop.
|
||||
pub fn release(self, _py: Python<'_>) {
|
||||
// First move self into a ManuallyDrop, so that PyBuffer::drop will
|
||||
// never be called. (It would acquire the GIL and call PyBuffer_Release
|
||||
|
|
Loading…
Reference in a new issue