HepMC3 event record library
Public Member Functions | Static Public Member Functions | Data Fields | Protected Attributes
memoryview Class Reference
+ Inheritance diagram for memoryview:
+ Collaboration diagram for memoryview:

Public Member Functions

 memoryview (const buffer_info &info)
 
 PYBIND11_DEPRECATED ("Use reinterpret_borrow<object>() or reinterpret_steal<object>()") object(handle h
 
handle release ()
 
template<typename T >
cast () const &
 
template<typename T >
cast ()&&
 
PyObject * ptr () const
 Return the underlying PyObject * pointer. More...
 
PyObject *& ptr ()
 
const handleinc_ref () const &
 
const handledec_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
 
bool check () const
 

Static Public Member Functions

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_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)
 
template<typename T >
static memoryview from_buffer (const T *ptr, detail::any_container< ssize_t > shape, detail::any_container< ssize_t > strides)
 

Data Fields

bool is_borrowed: handle(h) { if (is_borrowed) inc_ref()
 

Protected Attributes

PyObject * m_ptr = nullptr
 

Detailed Description

Definition at line 1394 of file pytypes.h.

Constructor & Destructor Documentation

memoryview ( const buffer_info info)
inlineexplicit

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.

Definition at line 1407 of file pytypes.h.

Member Function Documentation

const handle& dec_ref ( ) const
inlineinherited
\rst
Manually decrease the reference count of the Python object. Usually, it is
preferable to use the `object` class which derives from `handle` and calls
this function automatically. Returns a reference to itself.

Definition at line 199 of file pytypes.h.

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

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.

const handle& inc_ref ( ) const
inlineinherited
\rst
Manually increase the reference count of the Python object. Usually, it is
preferable to use the `object` class which derives from `handle` and calls
this function automatically. Returns a reference to itself.

Definition at line 192 of file pytypes.h.

operator bool ( ) const
inlineexplicitinherited

Return true when the handle wraps a valid Python object.

Definition at line 207 of file pytypes.h.

bool operator== ( const handle h) const
inlineinherited
\rst
Deprecated: Check that the underlying pointers are the same.
Equivalent to ``obj1 is obj2`` in Python.

Definition at line 213 of file pytypes.h.

PyObject* ptr ( ) const
inlineinherited

Return the underlying PyObject * pointer.

Definition at line 184 of file pytypes.h.

handle release ( )
inlineinherited
\rst
Resets the internal pointer to ``nullptr`` without decreasing the
object's reference count. The function returns a raw handle to the original
Python object.

Definition at line 249 of file pytypes.h.

References handle::handle().


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