docs: mention PyBuffer

This commit is contained in:
David Hewitt 2022-08-25 19:06:22 +01:00
parent 8ab3f5fc47
commit 7c231a2372
2 changed files with 5 additions and 2 deletions

View File

@ -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` |

View File

@ -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