# mpi4py.MPI.buffer

class mpi4py.MPI.buffer

  Bases: `object`

  Buffer.

  static __new__(cls, buf, /)
    Parameters:

      buf (Buffer)

    Return type:

      Self

  Methods Summary

  `allocate`(nbytes[, clear]) | Buffer allocation.
  `cast`(format[, shape]) | Cast to a `memoryview` with new format or shape.
  `fromaddress`(address, nbytes[, readonly]) | Buffer from address and size in bytes.
  `frombuffer`(obj[, readonly]) | Buffer from buffer-like object.
  `release`() | Release the underlying buffer exposed by the buffer object.
  `tobytes`([order]) | Return the data in the buffer as a byte string.
  `toreadonly`() | Return a readonly version of the buffer object.

  Attributes Summary

  `address` | Buffer address.
  `format` | Format of each element.
  `itemsize` | Size (in bytes) of each element.
  `nbytes` | Buffer size (in bytes).
  `obj` | Object exposing buffer.
  `readonly` | Buffer is read-only.

  Methods Documentation

  static allocate(nbytes, clear=False)

    Buffer allocation.

    Parameters:

      - nbytes (int)

      - clear (bool)

    Return type:

      buffer

  cast(format, shape=Ellipsis)

    Cast to a `memoryview` with new format or shape.

    Parameters:

      - format (str)

      - shape (list[int] | tuple[int, ...])

    Return type:

      memoryview

  static fromaddress(address, nbytes, readonly=False)

    Buffer from address and size in bytes.

    Parameters:

      - address (int)

      - nbytes (int)

      - readonly (bool)

    Return type:

      buffer

  static frombuffer(obj, readonly=False)

    Buffer from buffer-like object.

    Parameters:

      - obj (Buffer)

      - readonly (bool)

    Return type:

      buffer

  release()

    Release the underlying buffer exposed by the buffer object.

    Return type:

      None

  tobytes(order=None)

    Return the data in the buffer as a byte string.

    Parameters:

      order (str | None)

    Return type:

      bytes

  toreadonly()

    Return a readonly version of the buffer object.

    Return type:

      buffer

  Attributes Documentation

  address

    Buffer address.

  format

    Format of each element.

  itemsize

    Size (in bytes) of each element.

  nbytes

    Buffer size (in bytes).

  obj

    Object exposing buffer.

  readonly

    Buffer is read-only.