Public Member Functions | Static Public Member Functions | List of all members
memoryview Class Reference

#include <pytypes.h>

Inheritance diagram for memoryview:
Inheritance graph
[legend]

Public Member Functions

 memoryview (const buffer_info &info)
 
- Public Member Functions inherited from object
template<typename T >
T cast () &&
 
template<typename T >
T cast () const &
 
template<>
void cast () const &
 
 object ()=default
 
 object (const object &o)
 Copy constructor; always increases the reference count. More...
 
 object (handle h, borrowed_t)
 
 object (handle h, stolen_t)
 
 object (object &&other) noexcept
 Move constructor; steals the object from other and preserves its reference count. More...
 
objectoperator= (const object &other)
 
objectoperator= (object &&other) noexcept
 
 PYBIND11_DEPRECATED ("Use reinterpret_borrow<object>() or reinterpret_steal<object>()") object(handle h
 
handle release ()
 
 ~object ()
 Destructor; automatically calls handle::dec_ref() More...
 
- Public Member Functions inherited from handle
template<typename T >
T cast () const
 
template<>
void cast () const
 
bool check () const
 
const handledec_ref () const &
 
 handle ()=default
 The default constructor creates a handle with a nullptr-valued pointer. More...
 
template<typename T , detail::enable_if_t< detail::all_of< detail::none_of< std::is_base_of< handle, T >, detail::is_pyobj_ptr_or_nullptr_t< T >>, std::is_convertible< T, PyObject * >>::value, int > = 0>
 handle (T &obj)
 Enable implicit conversion through T::operator PyObject *(). More...
 
template<typename T , detail::enable_if_t< detail::is_pyobj_ptr_or_nullptr_t< T >::value, int > = 0>
 handle (T ptr)
 
const handleinc_ref () const &
 
 operator bool () const
 Return true when the handle wraps a valid Python object. More...
 
bool operator!= (const handle &h) const
 
bool operator== (const handle &h) const
 
PyObject *& ptr ()
 
PyObject * ptr () const
 Return the underlying PyObject * pointer. More...
 

Static Public Member Functions

template<typename T >
static memoryview from_buffer (const T *ptr, detail::any_container< ssize_t > shape, detail::any_container< ssize_t > strides)
 
static memoryview from_buffer (const void *ptr, ssize_t itemsize, const char *format, detail::any_container< ssize_t > shape, detail::any_container< ssize_t > strides)
 
template<typename T >
static memoryview from_buffer (T *ptr, detail::any_container< ssize_t > shape, detail::any_container< ssize_t > strides, bool readonly=false)
 
static memoryview from_buffer (void *ptr, ssize_t itemsize, const char *format, detail::any_container< ssize_t > shape, detail::any_container< ssize_t > strides, bool readonly=false)
 
static memoryview from_memory (const void *mem, ssize_t size)
 
static memoryview from_memory (void *mem, ssize_t size, bool readonly=false)
 
- Static Public Member Functions inherited from handle
static std::size_t inc_ref_counter ()
 

Additional Inherited Members

- Public Attributes inherited from object
bool is_borrowed: handle(h) { if (is_borrowed) { inc_ref()
 
- Protected Attributes inherited from handle
PyObject * m_ptr = nullptr
 

Detailed Description

Definition at line 2288 of file pytypes.h.

Constructor & Destructor Documentation

◆ memoryview()

memoryview::memoryview ( const buffer_info info)
inlineexplicit

\rst Creates memoryview from buffer_info.

buffer_info must be created from buffer::request(). Otherwise throws an exception.

For creating a memoryview from objects that support buffer protocol, use memoryview(const object& obj) instead of this constructor. \endrst

Definition at line 2301 of file pytypes.h.

Member Function Documentation

◆ from_buffer() [1/4]

template<typename T >
static memoryview memoryview::from_buffer ( const T ptr,
detail::any_container< ssize_t shape,
detail::any_container< ssize_t strides 
)
inlinestatic

Definition at line 2367 of file pytypes.h.

◆ from_buffer() [2/4]

static memoryview memoryview::from_buffer ( const void *  ptr,
ssize_t  itemsize,
const char *  format,
detail::any_container< ssize_t shape,
detail::any_container< ssize_t strides 
)
inlinestatic

Definition at line 2344 of file pytypes.h.

◆ from_buffer() [3/4]

template<typename T >
static memoryview memoryview::from_buffer ( T ptr,
detail::any_container< ssize_t shape,
detail::any_container< ssize_t strides,
bool  readonly = false 
)
inlinestatic

Definition at line 2354 of file pytypes.h.

◆ from_buffer() [4/4]

static memoryview memoryview::from_buffer ( void *  ptr,
ssize_t  itemsize,
const char *  format,
detail::any_container< ssize_t shape,
detail::any_container< ssize_t strides,
bool  readonly = false 
)
static

\rst Creates memoryview from static buffer.

This method is meant for providing a memoryview for C/C++ buffer not managed by Python. The caller is responsible for managing the lifetime of ptr and format, which MUST outlive the memoryview constructed here.

See also: Python C API documentation for PyMemoryView_FromBuffer_.

.. _PyMemoryView_FromBuffer: https://docs.python.org/c-api/memoryview.html#c.PyMemoryView_FromBuffer

:param ptr: Pointer to the buffer. :param itemsize: Byte size of an element. :param format: Pointer to the null-terminated format string. For homogeneous Buffers, this should be set to format_descriptor<T>::value. :param shape: Shape of the tensor (1 entry per dimension). :param strides: Number of bytes between adjacent entries (for each per dimension). :param readonly: Flag to indicate if the underlying storage may be written to. \endrst

◆ from_memory() [1/2]

static memoryview memoryview::from_memory ( const void *  mem,
ssize_t  size 
)
inlinestatic

Definition at line 2395 of file pytypes.h.

◆ from_memory() [2/2]

static memoryview memoryview::from_memory ( void *  mem,
ssize_t  size,
bool  readonly = false 
)
inlinestatic

\rst Creates memoryview from static memory.

This method is meant for providing a memoryview for C/C++ buffer not managed by Python. The caller is responsible for managing the lifetime of mem, which MUST outlive the memoryview constructed here.

See also: Python C API documentation for PyMemoryView_FromBuffer_.

.. _PyMemoryView_FromMemory: https://docs.python.org/c-api/memoryview.html#c.PyMemoryView_FromMemory \endrst

Definition at line 2386 of file pytypes.h.


The documentation for this class was generated from the following file:


gtsam
Author(s):
autogenerated on Thu Dec 19 2024 04:08:51