package py

  1. Overview
  2. Docs

Object defines functions for working with generic Python objects

Object defines functions for working with generic Python objects

type t

t is a pointer to PyObject

val is_null : t -> bool

Returns true if an object is null

val is_none : t -> bool

Returns true if an object is None

val incref : t -> unit

Increments reference count for an object

val decref : t -> unit

Decrements reference count for an object

val length : t -> int64

Returns the length of an object

val get_item : t -> t -> t

Returns the element at the given index

val get_item_s : t -> string -> t

Returns the element at the given string index

val get_item_i : t -> int -> t

Returns the element at the given integer index

val del_item : t -> t -> unit

Deletes the item at the given index

val del_item_s : t -> string -> unit

Deletes the item at the given string index

val del_item_i : t -> int -> unit

Deletes the item at the given integer index

val set_item : t -> t -> t -> unit

Sets the item at the given index

val set_item_s : t -> string -> t -> unit

Sets the item at the given string index

val set_item_i : t -> int -> t -> unit

Sets the item at the given integer index

val get_attr : t -> t -> t
val get_attr_s : t -> string -> t
val del_attr : t -> t -> unit
val del_attr_s : t -> string -> unit
val set_attr : t -> t -> t -> unit
val set_attr_s : t -> string -> t -> unit
val has_attr : t -> t -> bool
val has_attr_s : t -> string -> bool
val to_string : t -> string

Convert an object to OCaml string

val to_bytes : t -> bytes

Convert an object to OCaml bytes

val to_int : t -> int

Convert an object to OCaml int

val to_int64 : t -> int64

Convert an object to OCaml int64

val to_float : t -> float

Convert an object to OCaml float

val to_bool : t -> bool

Convert an object to OCaml bool

val from_bool : bool -> t

Create a boolean object

val none : unit -> t
val compare : t -> t -> Py__.Py_base.op -> bool
val to_array : (t -> 'a) -> t -> 'a array
val to_list : (t -> 'a) -> t -> 'a list
val contains : t -> t -> bool
val concat : t -> t -> t
val call : ?args:t array -> ?kwargs:(t * t) list -> t -> t

Call a Python Object

val call_method : ?args:t array -> ?kwargs:(t * t) list -> t -> string -> t

Call a method on Python Object

val pp : Stdlib.Format.formatter -> t -> unit

Top-level pretty printer.

val to_c_ptr : Py__.Py_base.pyobject -> unit Ctypes.ptr
val of_c_ptr : unit Ctypes.ptr -> Py__.Py_base.pyobject
val capsule_c_pointer : t -> string option -> unit Ctypes.ptr

Extract the C pointer from a capsule

OCaml

Innovation. Community. Security.