# mpi4py.MPI.Datatype

class mpi4py.MPI.Datatype

  Bases: `object`

  Datatype object.

  static __new__(cls, datatype=None)
    Parameters:

      datatype (Datatype | None)

    Return type:

      Self

  Methods Summary

  `Commit`() | Commit the datatype.
  `Create_contiguous`(count) | Create a contiguous datatype.
  `Create_darray`(size, rank, gsizes, distribs, ...) | Create a datatype for a distributed array on Cartesian process grids.
  `Create_f90_complex`(p, r) | Return a bounded complex datatype.
  `Create_f90_integer`(r) | Return a bounded integer datatype.
  `Create_f90_real`(p, r) | Return a bounded real datatype.
  `Create_hindexed`(blocklengths, displacements) | Create an indexed datatype.
  `Create_hindexed_block`(blocklength, displacements) | Create an indexed datatype with constant-sized blocks.
  `Create_hvector`(count, blocklength, stride) | Create a vector (strided) datatype with stride in bytes.
  `Create_indexed`(blocklengths, displacements) | Create an indexed datatype.
  `Create_indexed_block`(blocklength, displacements) | Create an indexed datatype with constant-sized blocks.
  `Create_keyval`([copy_fn, delete_fn, nopython]) | Create a new attribute key for datatypes.
  `Create_resized`(lb, extent) | Create a datatype with a new lower bound and extent.
  `Create_struct`(blocklengths, displacements, ...) | Create a general composite (struct) datatype.
  `Create_subarray`(sizes, subsizes, starts[, order]) | Create a datatype for a subarray of a multidimensional array.
  `Create_vector`(count, blocklength, stride) | Create a vector (strided) datatype.
  `Delete_attr`(keyval) | Delete attribute value associated with a key.
  `Dup`() | Duplicate a datatype.
  `Free`() | Free the datatype.
  `Free_keyval`(keyval) | Free an attribute key for datatypes.
  `Get_attr`(keyval) | Retrieve attribute value by key.
  `Get_contents`() | Return the input arguments used to create a datatype.
  `Get_envelope`() | Return the number of input arguments used to create a datatype.
  `Get_extent`() | Return lower bound and extent of datatype.
  `Get_name`() | Get the print name for this datatype.
  `Get_size`() | Return the number of bytes occupied by entries in the datatype.
  `Get_true_extent`() | Return the true lower bound and extent of a datatype.
  `Get_value_index`(value, index) | Return a predefined pair datatype.
  `Match_size`(typeclass, size) | Find a datatype matching a specified size in bytes.
  `Pack`(inbuf, outbuf, position, comm) | Pack into contiguous memory according to datatype.
  `Pack_external`(datarep, inbuf, outbuf, position) | Pack into contiguous memory according to datatype.
  `Pack_external_size`(datarep, count) | Determine the amount of space needed to pack a message.
  `Pack_size`(count, comm) | Determine the amount of space needed to pack a message.
  `Set_attr`(keyval, attrval) | Store attribute value associated with a key.
  `Set_name`(name) | Set the print name for this datatype.
  `Unpack`(inbuf, position, outbuf, comm) | Unpack from contiguous memory according to datatype.
  `Unpack_external`(datarep, inbuf, position, outbuf) | Unpack from contiguous memory according to datatype.
  `decode`() | Convenience method for decoding a datatype.
  `f2py`(arg) |
  `free`() | Call `Free` if not null or predefined.
  `fromcode`(code) | Get predefined MPI datatype from character code or type string.
  `fromhandle`(handle) | Create object from MPI handle.
  `fromint`(arg, /) | Translate integer handle to object.
  `py2f`() |
  `tocode`() | Get character code or type string from predefined MPI datatype.
  `toint`() | Translate object to integer handle.

  Attributes Summary

  `combiner` | Combiner.
  `contents` | Contents.
  `envelope` | Envelope.
  `extent` | Extent.
  `handle` | MPI handle.
  `is_named` | Is a named datatype.
  `is_predefined` | Is a predefined datatype.
  `lb` | Lower bound.
  `name` | Print name.
  `size` | Size (in bytes).
  `true_extent` | True extent.
  `true_lb` | True lower bound.
  `true_ub` | True upper bound.
  `typechar` | Character code.
  `typestr` | Type string.
  `ub` | Upper bound.

  Methods Documentation

  Commit()

    Commit the datatype.

    Return type:

      Self

  Create_contiguous(count)

    Create a contiguous datatype.

    Parameters:

      count (int)

    Return type:

      Self

  Create_darray(size, rank, gsizes, distribs, dargs, psizes, order=ORDER_C)

    Create a datatype for a distributed array on Cartesian process grids.

    Parameters:

      - size (int)

      - rank (int)

      - gsizes (Sequence[int])

      - distribs (Sequence[int])

      - dargs (Sequence[int])

      - psizes (Sequence[int])

      - order (int)

    Return type:

      Self

  classmethod Create_f90_complex(p, r)

    Return a bounded complex datatype.

    Parameters:

      - p (int)

      - r (int)

    Return type:

      Self

  classmethod Create_f90_integer(r)

    Return a bounded integer datatype.

    Parameters:

      r (int)

    Return type:

      Self

  classmethod Create_f90_real(p, r)

    Return a bounded real datatype.

    Parameters:

      - p (int)

      - r (int)

    Return type:

      Self

  Create_hindexed(blocklengths, displacements)

    Create an indexed datatype.

    Note

    Displacements are measured in bytes.

    Parameters:

      - blocklengths (Sequence[int])

      - displacements (Sequence[int])

    Return type:

      Self

  Create_hindexed_block(blocklength, displacements)

    Create an indexed datatype with constant-sized blocks.

    Note

    Displacements are measured in bytes.

    Parameters:

      - blocklength (int)

      - displacements (Sequence[int])

    Return type:

      Self

  Create_hvector(count, blocklength, stride)

    Create a vector (strided) datatype with stride in bytes.

    Parameters:

      - count (int)

      - blocklength (int)

      - stride (int)

    Return type:

      Self

  Create_indexed(blocklengths, displacements)

    Create an indexed datatype.

    Parameters:

      - blocklengths (Sequence[int])

      - displacements (Sequence[int])

    Return type:

      Self

  Create_indexed_block(blocklength, displacements)

    Create an indexed datatype with constant-sized blocks.

    Parameters:

      - blocklength (int)

      - displacements (Sequence[int])

    Return type:

      Self

  classmethod Create_keyval(copy_fn=None, delete_fn=None, nopython=False)

    Create a new attribute key for datatypes.

    Parameters:

      - copy_fn (Callable[[Datatype, int, Any], Any] | None)

      - delete_fn (Callable[[Datatype, int, Any], None] | None)

      - nopython (bool)

    Return type:

      int

  Create_resized(lb, extent)

    Create a datatype with a new lower bound and extent.

    Parameters:

      - lb (int)

      - extent (int)

    Return type:

      Self

  classmethod Create_struct(blocklengths, displacements, datatypes)

    Create a general composite (struct) datatype.

    Note

    Displacements are measured in bytes.

    Parameters:

      - blocklengths (Sequence[int])

      - displacements (Sequence[int])

      - datatypes (Sequence[Datatype])

    Return type:

      Self

  Create_subarray(sizes, subsizes, starts, order=ORDER_C)

    Create a datatype for a subarray of a multidimensional array.

    Parameters:

      - sizes (Sequence[int])

      - subsizes (Sequence[int])

      - starts (Sequence[int])

      - order (int)

    Return type:

      Self

  Create_vector(count, blocklength, stride)

    Create a vector (strided) datatype.

    Parameters:

      - count (int)

      - blocklength (int)

      - stride (int)

    Return type:

      Self

  Delete_attr(keyval)

    Delete attribute value associated with a key.

    Parameters:

      keyval (int)

    Return type:

      None

  Dup()

    Duplicate a datatype.

    Return type:

      Self

  Free()

    Free the datatype.

    Return type:

      None

  classmethod Free_keyval(keyval)

    Free an attribute key for datatypes.

    Parameters:

      keyval (int)

    Return type:

      int

  Get_attr(keyval)

    Retrieve attribute value by key.

    Parameters:

      keyval (int)

    Return type:

      int | Any | None

  Get_contents()

    Return the input arguments used to create a datatype.

    Return type:

      tuple[list[int], list[int], list[int], list[Datatype]]

  Get_envelope()

    Return the number of input arguments used to create a datatype.

    Return type:

      tuple[int, int, int, int, int]

  Get_extent()

    Return lower bound and extent of datatype.

    Return type:

      tuple[int, int]

  Get_name()

    Get the print name for this datatype.

    Return type:

      str

  Get_size()

    Return the number of bytes occupied by entries in the datatype.

    Return type:

      int

  Get_true_extent()

    Return the true lower bound and extent of a datatype.

    Return type:

      tuple[int, int]

  classmethod Get_value_index(value, index)

    Return a predefined pair datatype.

    Parameters:

      - value (Datatype)

      - index (Datatype)

    Return type:

      Self

  classmethod Match_size(typeclass, size)

    Find a datatype matching a specified size in bytes.

    Parameters:

      - typeclass (int)

      - size (int)

    Return type:

      Self

  Pack(inbuf, outbuf, position, comm)

    Pack into contiguous memory according to datatype.

    Parameters:

      - inbuf (BufSpec)

      - outbuf (BufSpec)

      - position (int)

      - comm (Comm)

    Return type:

      int

  Pack_external(datarep, inbuf, outbuf, position)

    Pack into contiguous memory according to datatype.

    Uses the portable data representation external32.

    Parameters:

      - datarep (str)

      - inbuf (BufSpec)

      - outbuf (BufSpec)

      - position (int)

    Return type:

      int

  Pack_external_size(datarep, count)

    Determine the amount of space needed to pack a message.

    Uses the portable data representation external32.

    Note

    Returns an upper bound measured in bytes.

    Parameters:

      - datarep (str)

      - count (int)

    Return type:

      int

  Pack_size(count, comm)

    Determine the amount of space needed to pack a message.

    Note

    Returns an upper bound measured in bytes.

    Parameters:

      - count (int)

      - comm (Comm)

    Return type:

      int

  Set_attr(keyval, attrval)

    Store attribute value associated with a key.

    Parameters:

      - keyval (int)

      - attrval (Any)

    Return type:

      None

  Set_name(name)

    Set the print name for this datatype.

    Parameters:

      name (str)

    Return type:

      None

  Unpack(inbuf, position, outbuf, comm)

    Unpack from contiguous memory according to datatype.

    Parameters:

      - inbuf (BufSpec)

      - position (int)

      - outbuf (BufSpec)

      - comm (Comm)

    Return type:

      int

  Unpack_external(datarep, inbuf, position, outbuf)

    Unpack from contiguous memory according to datatype.

    Uses the portable data representation external32.

    Parameters:

      - datarep (str)

      - inbuf (BufSpec)

      - position (int)

      - outbuf (BufSpec)

    Return type:

      int

  decode()

    Convenience method for decoding a datatype.

    Return type:

      tuple[Datatype, str, dict[str, Any]]

  classmethod f2py(arg)
    Parameters:

      arg (int)

    Return type:

      Datatype

  free()

    Call `Free` if not null or predefined.

    Return type:

      None

  classmethod fromcode(code)

    Get predefined MPI datatype from character code or type string.

    Parameters:

      code (str)

    Return type:

      Datatype

  classmethod fromhandle(handle)

    Create object from MPI handle.

    Parameters:

      handle (int)

    Return type:

      Datatype

  classmethod fromint(arg, /)

    Translate integer handle to object.

    Parameters:

      arg (int)

    Return type:

      Datatype

  py2f()
    Return type:

      int

  tocode()

    Get character code or type string from predefined MPI datatype.

    Return type:

      str

  toint()

    Translate object to integer handle.

    Return type:

      int

  Attributes Documentation

  combiner

    Combiner.

  contents

    Contents.

  envelope

    Envelope.

  extent

    Extent.

  handle

    MPI handle.

  is_named

    Is a named datatype.

  is_predefined

    Is a predefined datatype.

  lb

    Lower bound.

  name

    Print name.

  size

    Size (in bytes).

  true_extent

    True extent.

  true_lb

    True lower bound.

  true_ub

    True upper bound.

  typechar

    Character code.

  typestr

    Type string.

  ub

    Upper bound.