Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagepy
cdef size_t payload = 0
payload = d.xtc.extent - sizeof(Xtc)
view_ptr += sizeof(Dgram) + payload

From C++ Dgram to Python

Python Dgram object can be created in two ways:

  1. Using file descriptor: This way, a memory space is allocated and deallocated by the Dgram class.
  2. Using view (ant buffer-interface Python objects): Dgram class handles reference count for the given view object. 

One way to cleanly pass a C++ Dgram to Python is to copy the contents to a buffer-interface object and create a Python Dgram from it. With this method, the life-time of the memory location is handled by the Python Dgram class.