package pyml

  1. Overview
  2. Docs
OCaml bindings for Python

Install

Dune Dependency

Authors

Maintainers

Sources

20211015.tar.gz
sha512=79237ab56a2e439e785f4d873abd603fdaa51dbbb1258efb25102ca897826cf4d5d15e8467f324df85bba3c61995ceee8fb82d0808cda0da8010e024a78307aa

doc/pyml/Pycaml/index.html

Module PycamlSource

Embedding Python into OCaml.

(C) arty 2002

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

A Derivative of Art Yerkes' 2002 Pycaml module.

Modifications (C) 2005 Dr. Thomas Fischbacher, Giuliano Bordignon, Dr. Hans Fangohr, SES, University of Southampton

More modifications are by Barry Schwartz. Copyright (C) 2009 Barry Schwartz.

Adapted for py.ml by Thierry Martinez. Copyright (C) 2016 Thierry Martinez.

Background Information

The original code is available in Debian as package "pycaml".

For various reasons, we hijacked it so that we can easily both fix bugs and extend it. This is permitted by the Pycaml license (the GNU LGPL).

Note: the layout and hierarchical structure of the documentation could need some more work.

OCaml Types, Python Types, and general issues of typing

Sourcetype pyobject = Py.Object.t

Python objects are wrapped up within OCaml as entities of type pyobject.

The following types are slightly esoteric; normally, users of this module should not have any need to access them.

Sourcetype funcptr
Sourcetype funcent = funcptr * int * int * bool
Sourcetype pymodule_func = {
  1. pyml_name : string;
  2. pyml_func : pyobject -> pyobject;
  3. pyml_flags : int;
  4. pyml_doc : string;
}
Sourceval py_profile_reset : unit -> unit
Sourceval py_profile_report : unit -> (string * float * float) array
Sourceval py_activate_profiling : unit -> bool
Sourceval py_deactivate_profiling : unit -> bool

As Python is a dynamically typed language, pyobject values may represent entities of very different nature. The pytype function maps a pyobject to its type, or rather, a selection of types that have been made known to OCaml. The default for "unknown" values is OtherType.

Note (for advanced users only): This in particular holds for PyCObject values, which are used at present to wrap up OCaml values opaquely within Python values: at present, these appear to be of type OtherType, but there might be good reason to change this in the future.

Sourcetype pyobject_type =
  1. | TupleType
  2. | BytesType
  3. | UnicodeType
  4. | BoolType
  5. | IntType
  6. | FloatType
  7. | ListType
  8. | NoneType
  9. | CallableType
  10. | ModuleType
  11. | ClassType
  12. | TypeType
  13. | DictType
  14. | NullType
  15. | CamlpillType
  16. | OtherType
  17. | EitherStringType
  18. | CamlpillSubtype of string
  19. | AnyType
Sourcetype pyerror_type =
  1. | Pyerr_Exception
  2. | Pyerr_StandardError
  3. | Pyerr_ArithmeticError
  4. | Pyerr_LookupError
  5. | Pyerr_AssertionError
  6. | Pyerr_AttributeError
  7. | Pyerr_EOFError
  8. | Pyerr_EnvironmentError
  9. | Pyerr_FloatingPointError
  10. | Pyerr_IOError
  11. | Pyerr_ImportError
  12. | Pyerr_IndexError
  13. | Pyerr_KeyError
  14. | Pyerr_KeyboardInterrupt
  15. | Pyerr_MemoryError
  16. | Pyerr_NameError
  17. | Pyerr_NotImplementedError
  18. | Pyerr_OSError
  19. | Pyerr_OverflowError
  20. | Pyerr_ReferenceError
  21. | Pyerr_RuntimeError
  22. | Pyerr_SyntaxError
  23. | Pyerr_SystemExit
  24. | Pyerr_TypeError
  25. | Pyerr_ValueError
  26. | Pyerr_ZeroDivisionError
Sourceexception Pycaml_exn of pyerror_type * string

Also note the existence of pytype_name, which maps python types to human-readable strings.

Initialization

The Python interpreter has to be initialized, which is done via py_initialize. Note that this module does call this function automatically when it is initialized itself, so the end user does not have to worry about this.

Note that Python initialization seems to be idempotent, so there should not be any problems if one starts up a python interpreter first, and then loads a shared object via Python's foreign function interface which itself initializes OCaml and pycaml. (Note: However, this still needs more testing!)

Sourceval py_initialize : unit -> unit
Sourceval py_finalize : unit -> unit

Functions from the original Pycaml

There is a collection of functions from the original Pycaml module which are not-too-well-documented. For some of them, there are examples available, and often, one can guess what they are supposed to do from their name and type. (Admittedly, this is a quite unsatisfactory state of affairs, but on the other hand, as it turns out, we will have to use only very few of them. So for now, if there is a question, look at the source, or ask t.fischbacher\@soton.ac.uk.)

In order not to clutter the Pycaml documentation with a block of unreadable code, they have been moved to the last section.

On wrapping up Ocaml values for Python

The Pycaml functions pywrap_value and pyunwrap_value are elementary low-level primitives to make opaque Python values that hold OCaml values. As Python is a dynamically typed language, and OCaml is a statically typed language, and both achieve safety in a somewhat misaligned way, this interface may be considered as dangerous. In fact, it allows one to break OCaml type safety by mapping a statically typed value to a dynamically typed Python value and back.

This means that a Python user handing a wrapped-up ocaml value of a different type than expected over to an OCaml callback may crash the system.

This module provides an extension to the original Pycaml which will have added checks that prevent precisely such a situation and therefore is safer. Note however, that at the moment, it is only foolproof if one does not mix this up with other PyCObject Python values. (Presumably, it can be tightened up by introducing a new primitive Python type PyCamlObject. TODO.)

Sourceval pywrap_value : 'a -> pyobject
Sourceval pyunwrap_value : pyobject -> 'a

Genuine Extensions to the original Pycaml

Converting values and handling errors

Sourceval py_repr : pyobject -> string
Sourceval pylist_fromarray : pyobject array -> pyobject
Sourceval pylist_toarray : pyobject -> pyobject array

Map an OCaml array of Python values to a Python list and vice versa. (This was just missing.)

Sourceval pylist_set : pyobject -> int -> pyobject -> unit
Sourceval pylist_get : pyobject -> int -> pyobject
Sourceval pyrefcount : pyobject -> int
Sourceval pywrap_closure_docstring : string -> (pyobject -> pyobject) -> pyobject

While the functions in ocaml.* should not be made visible to end users directly, it may nevertheless be helpful to be able to set docstrings on them.

Sourceval pytype_name : pyobject_type -> string

Return a name-string for an Ocaml Python-Object-Type value. Used mainly for debugging and in error messages.

Sourceval python_last_value : unit -> pyobject

Return the last value that was computed interactively at the Python prompt

Sourceval py_true : unit -> pyobject
Sourceval py_false : unit -> pyobject
Sourceval py_is_true : pyobject -> bool
Sourceval register_for_python : (string * pyobject) array -> unit

A convenient function to make a collection of pyobject values (which usually will be OCaml callbacks) known to Python in one go. The strings give the names under which the corresponding values should appear in Python's "ocaml" module, which Pycaml will add to Python and automatically import on the Python side.

Note that as a convention, one must not register names that start with the string "example_" or "sys_", as those are reserved for internal use by Pycaml.

Sourceval register_pre_functions_for_python : (string * (string -> pyobject)) array -> unit
Sourceval float_array_to_python : float array -> pyobject
Sourceval int_array_to_python : int array -> pyobject

These functions provides a quick and convenient way to pass a simple array of numbers to Python. Note that neither on the OCaml nor on the Python side, the special data structure for efficient manipulation of large numerical arrays is used (OCaml: bigarray, Python: numarray). Rather, this just maps ordinary arrays.

Sourceval py_float_tensor : ?init:(int array -> float) -> int array -> pyobject * (int array -> pyobject -> unit)

This little helper creates a nested float array python structure that is supposed to represent a multi-indexed tensor, plus a function to set tensor entries.

Sourceval py_homogeneous_list_as_array : ?error_label:string -> ?length:int -> string -> (pyobject -> bool) -> (pyobject -> 'a) -> pyobject -> 'a array
Sourceval py_float_list_as_array : ?error_label:string -> ?length:int -> pyobject -> float array
Sourceval py_number_list_as_float_array : ?error_label:string -> ?length:int -> pyobject -> float array
Sourceval py_int_list_as_array : ?error_label:string -> ?length:int -> pyobject -> int array
Sourceval py_string_list_as_array : ?error_label:string -> ?length:int -> pyobject -> string array
Sourceval py_list_list_as_array : ?error_label:string -> ?length:int -> pyobject -> pyobject array
Sourceval py_list_list_as_array2 : ?error_label:string -> ?length:int -> pyobject -> pyobject array array
Sourceval py_float_list_list_as_array : ?error_label:string -> ?length_outer:int -> ?length_inner:int -> pyobject -> float array array
Sourceval py_number_list_list_as_float_array : ?error_label:string -> ?length_outer:int -> ?length_inner:int -> pyobject -> float array array
Sourceval py_int_list_list_as_array : ?error_label:string -> ?length_outer:int -> ?length_inner:int -> pyobject -> int array array
Sourceval py_string_list_list_as_array : ?error_label:string -> ?length_outer:int -> ?length_inner:int -> pyobject -> string array array
Sourceval unpythonizing_function : ?name:string -> ?catch_weird_exceptions:bool -> ?extra_guards:(pyobject -> string option) array -> ?expect_tuple:bool -> pyobject_type array -> (pyobject array -> 'a) -> pyobject -> 'a
Sourceval pythonize_string : string -> pyobject
Sourceval unpythonize_string : pyobject -> string
Sourceval python_interfaced_function : ?name:string -> ?catch_weird_exceptions:bool -> ?doc:string -> ?extra_guards:(pyobject -> string option) array -> pyobject_type array -> (pyobject array -> pyobject) -> pyobject

This helper simplifies the creation of OCaml callbacks that can be registered in Python's "ocaml" module.

First argument: An array of pyobject_type Python types.

Second argument: A "body" function B mapping an OCaml array of Python values to a Python return value.

Optional argument: An array of extra checks to be performed on the arguments, one by one, returning an optional error message.

The body function (as well as the optional checks) will be wrapped up in code that first checks for the correct number and the specified Python types of arguments, so B can rely on the n'th entry of its Python argument array being of the Python type specified in the n'th position of the type array.

XXX Note: we need examples in the documentation!

Sourceval python_pre_interfaced_function : ?catch_weird_exceptions:bool -> ?doc:string -> ?extra_guards:(pyobject -> string option) array -> pyobject_type array -> (pyobject array -> pyobject) -> string -> pyobject
Sourceval register_ocamlpill_types : string array -> unit

Sometimes, we want to manipulate complicated structures via Python which are implemented in OCaml, and about whose interna only OCaml should know and have to worry. So, all that one can do from Python is to place such values in containers (tuples, lists) and retrieve them back, pass them around, and hand them over to OCaml callbacks.

In order to ensure type safety, we have to extend OCaml by a primitive dynamic type system for Python-wrapped OCaml values. This is based on the following assumptions:

  1. The number of different OCaml types we might want to make visible to Python is quite limited. (In particular, we do not even try to properly support polymorphism.)
  2. Python should be allowed to take a peek at the type name of a wrapped OCaml value at runtime

Thus, before one can opaquely wrap up OCaml values in "ocamlpills" for Python, one has to register a type name with Pycaml. From the Python side, the function ocaml.sys_ocamlpill_type(x) will map the ocamlpill x to the registered type string.

py.ml: Pill types are not required to be registered. This function does nothing and is provided for compatibility only.

Sourceval ocamlpill_type_of : pyobject -> string
Sourceval pill_type_mismatch_exception : ?position:'a -> ?exn_name:string -> string -> string -> exn

Given an ocamlpill type name (which was registered before using register_ocamlpill_type), as well as a witness of the type in question in form of a prototypical OCaml value, make a function that maps other OCaml values of the same type as the prototype to Python ocamlpills. This function is exported to python as ocaml.sys_ocamlpill_type.

Note: a simple type system hack is used to ensure that the wrapper function generated can only be applied to OCaml values of the proper type. One major drawback of this is that presumably, the prototypical object provided cannot be garbage collected until the wrapper function is. (A clever compiler might be able to figure out how to get rid of that, though.)

XXX Provide example code!

Sourceval check_pill_type : ?position:'a -> ?exn_name:string -> string -> pyobject -> unit
Sourceval make_ocamlpill_wrapper_unwrapper : string -> 'a -> ('a -> pyobject) * (pyobject -> 'a)

py.ml: the signature has been changed from string -> 'a -> ('a -> pyobject) * (pyobject -> 'b) to string -> 'a -> ('a -> pyobject) * (pyobject -> 'a). The second argument is ignored and the function calls Py.Capsule.make. Applying the function twice to the same type name raises a failure (Failure _).

Sourceval make_pill_wrapping : string -> 'a -> ('a -> pyobject) * (pyobject -> 'a)

py.ml: the signature has been changed from string -> 'a -> ('a -> pyobject) * (pyobject -> 'b) to string -> 'a -> ('a -> pyobject) * (pyobject -> 'a). The second argument is ignored and the function calls Py.Capsule.make. Applying the function twice to the same type name raises a failure (Failure _).

Sourceval py_optionally : (pyobject -> 'a) -> pyobject -> 'a option

Also, we want to be able to pass optional arguments from python to OCaml. The convention which we use for now is as follows:

  • Conceptually, an optional argument has to be a container monadic type.
  • The only thing offered by python which looks like such a thing is the list.
  • Hence, optional values are represented as 0-element or 1-element lists on the python side.

We then need ocaml functions that make it convenient to handle the automatic unpacking of such values. (XXX Note: we need examples in the documentation that show how to use this!)

Sourceval guarded_pyint_asint : pyobject -> int
Sourceval guarded_pyfloat_asfloat : pyobject -> float
Sourceval guarded_pynumber_asfloat : pyobject -> float
Sourceval guarded_pybytes_asstring : pyobject -> string
Sourceval guarded_pylist_toarray : pyobject -> pyobject array
Sourceval guarded_pytuple_toarray : pyobject -> pyobject array
Sourceval pycallable_asfun : pyobject -> pyobject array -> pyobject
Sourceval ocamlpill_hard_unwrap : pyobject -> 'a

This is semi-internal - It should only be used for writing other convenience type applicators that have their own way of doing the checking.

Running and evaluating Python from within OCaml

This function allows us to set Python's sys.argv

Sourceval set_python_argv : string array -> unit
Sourceval python_eval : string -> int

A convenience function for just letting the Python interpreter evaluate a block of Python code.

Sourceval python_load : string -> unit

One may use python_eval "execfile(...)" to load Python code into the interpreter. This function provides a slightly nicer way to do the same.

Note 1: Internally, this uses python_eval. The int return value is ignored, however.

Note 2: As we do not bother to properly escape quotation marks, this will not work as supposed on filenames containing double quotes. (Yes, this is a bug and should better be fixed!)

Sourceval python : unit -> int

Start the interactive python toplevel:

Sourceval ipython : unit -> int

Start the ipython toplevel. Note: for still unknown reasons, this does not seem to be 100% reliable, and especially seems to fail in many situations where Pycaml.ipython() is called not from the OCaml toplevel. May be some crazy terminal handling bug.

Addition: 23/01/2006 fangohr:

On Mac OS X, one of the problems is that there are often several Python installations. (One is provided by Apple, but usually a fink or Darwinport installation is actually meant to use.) For fink-python (the binary installed in /sw/bin, it helps to set the shell environment variable PYTHONHOME=/sw .

Then the call to ipython works fine.

Python Functions

All functions which are made visible from OCaml to python by means of register_for_python go into the Python module ocaml. Usually, one wants to place low-level interface functions there and build higher levels of abstraction on the python side on top of it which are more convenient (maybe object-oriented) to the Python end user. So, the user of a Python library that uses OCaml callbacks internally should (ideally) never notice the existence of the ocaml Python module.

The following names are pre-registered in the ocaml module. Note that they all start with the reserved prefixes sys_ or example_.

  • sys_ocamlpill_type: Function that maps an OCaml pill to a type string, so that Python can find out what a given pill is supposed to be. (The OCaml function name is ocamlpill_type_of.)
  • sys_python: Function that starts a recursive Python toplevel. This may seem strange at first, but actually is highly useful e.g. for providing some interactive control deep inside a contrived function during debugging. Return value is the value computed last on the recursive python command prompt.
  • example_test_interface: Function that just prints a test string.
  • example_the_answer: The number "42", put in the ocaml module by OCaml.
  • example_make_powers: A function mapping an integer n and a float p to the array

    [|1.0**p,2.0**p,...,(float_of_int n)**p|]

    .

  • example_hypotenuse: A function mapping two floatingpoint values x,y to sqrt(x**2+y**2).

It is instructive to have a look at the pycaml source providing the example_ entries to see how one can publish other constants and functions to Python.

Code Examples

The implementations of example_make_powers and example_hypotenuse demonstrate how to use python_interfaced_function:

   let _py_make_powers =
   python_interfaced_function
   ~extra_guards:
   [|(fun py_len ->
let len = pyint_asint py_len in
if len < 0
then Some "Negative Length"
else None);
   (fun _ -> None); (* This check never fails *)
   |]
   [|IntType;FloatType|]
   (fun py_args ->
   let len = pyint_asint py_args.(0)
   and pow = pyfloat_asdouble py_args.(1)
   in
float_array_to_python
(Array.init len (fun n -> let nn = float_of_int (n+1) in nn**pow)))
   and
   _py_hypotenuse_2d =
   python_interfaced_function
   [|FloatType;FloatType|]
   (fun py_args ->
   let x = pyfloat_asdouble py_args.(0)
   and y = pyfloat_asdouble py_args.(1)
   in pyfloat_fromdouble (sqrt(x*.x+.y*.y)))
   in
   register_for_python
   [|("example_make_powers", _py_make_powers);
   ("example_hypotenuse", _py_hypotenuse_2d);
   |]
   ;;

Appendix: signatures of undocumented functions from the original Pycaml

Sourceval pyerr_print : unit -> unit
Sourceval py_exit : int -> unit
Sourceval pyerr_printex : int -> unit
Sourceval py_setprogramname : string -> unit
Sourceval py_setpythonhome : string -> unit
Sourceval py_isinitialized : unit -> int
Sourceval pyrun_simplestring : string -> int
Sourceval pyrun_anyfile : (int * string) -> int
Sourceval pyrun_simplefile : (int * string) -> int
Sourceval pyrun_interactiveone : (int * string) -> int
Sourceval pyrun_interactiveloop : (int * string) -> int
Sourceval py_fdisinteractive : (int * string) -> int
Sourceval pyrun_anyfileex : (int * string * int) -> int
Sourceval pyrun_simplefileex : (int * string * int) -> int
Sourceval py_getprogramname : unit -> string
Sourceval py_getpythonhome : unit -> string
Sourceval py_getprogramfullpath : unit -> string
Sourceval py_getprefix : unit -> string
Sourceval py_getexecprefix : unit -> string
Sourceval py_getpath : unit -> string
Sourceval py_getversion : unit -> string
Sourceval py_getplatform : unit -> string
Sourceval py_getcopyright : unit -> string
Sourceval py_getcompiler : unit -> string
Sourceval py_getbuildinfo : unit -> string
Sourceval pyrun_string : (string * int * pyobject * pyobject) -> pyobject
Sourceval pyrun_file : (int * string * int * pyobject * pyobject) -> pyobject
Sourceval pyrun_fileex : (int * string * int * pyobject * pyobject * int) -> pyobject
Sourceval py_compilestring : (string * string * int) -> pyobject
Sourceval pyobject_print : (pyobject * int * int) -> int
Sourceval pyobject_repr : pyobject -> pyobject
Sourceval pyobject_str : pyobject -> pyobject
Sourceval pyobject_unicode : pyobject -> pyobject
Sourceval pyobject_richcompare : (pyobject * pyobject * int) -> pyobject
Sourceval pyobject_getattrstring : (pyobject * string) -> pyobject
Sourceval pyobject_getattr : (pyobject * pyobject) -> pyobject
Sourceval pyobject_istrue : pyobject -> int
Sourceval pyobject_not : pyobject -> int
Sourceval pycallable_check : pyobject -> int
Sourceval pyobject_hasattr : (pyobject * pyobject) -> int
Sourceval pyobject_richcomparebool : (pyobject * pyobject * int) -> int
Sourceval pyobject_setattrstring : (pyobject * string * pyobject) -> int
Sourceval pyobject_hasattrstring : (pyobject * string) -> int
Sourceval pyobject_compare : (pyobject * pyobject) -> int
Sourceval pyobject_setattr : (pyobject * pyobject * pyobject) -> int
Sourceval pyobject_hash : pyobject -> int64
Sourceval pybytes_size : pyobject -> int
Sourceval pystring_size : pyobject -> int
Sourceval pybytes_asstring : pyobject -> string
Sourceval pystring_asstring : pyobject -> string
Sourceval pybytes_asstringandsize : pyobject -> string
Sourceval pystring_asstringandsize : pyobject -> string
Sourceval pybytes_fromstring : string -> pyobject
Sourceval pystring_fromstring : string -> pyobject
Sourceval pybytes_format : (pyobject * pyobject) -> pyobject
Sourceval pystring_format : (pyobject * pyobject) -> pyobject
Sourceval pyunicode_asutf8string : pyobject -> pyobject
Sourceval pyunicode_asutf16string : pyobject -> pyobject
Sourceval pyunicode_asutf32string : pyobject -> pyobject
Sourceval pyunicode_decodeutf8 : (string * string option) -> pyobject
Sourceval pyunicode_decodeutf16 : (string * string option * int option) -> pyobject
Sourceval pyunicode_decodeutf32 : (string * string option * int option) -> pyobject
Sourceval pyunicode_fromunicode : (int -> int) -> int -> pyobject
Sourceval pyunicode_asunicode : pyobject -> int array
Sourceval pyunicode_getsize : pyobject -> int
Sourceval pydict_new : unit -> pyobject
Sourceval pydict_getitem : (pyobject * pyobject) -> pyobject
Sourceval pydict_setitem : (pyobject * pyobject * pyobject) -> int
Sourceval pydict_delitem : (pyobject * pyobject) -> int
Sourceval pydict_clear : pyobject -> unit
Sourceval pydict_keys : pyobject -> pyobject
Sourceval pydict_values : pyobject -> pyobject
Sourceval pydict_items : pyobject -> pyobject
Sourceval pydict_copy : pyobject -> pyobject
Sourceval pydict_size : pyobject -> int
Sourceval pydict_getitemstring : (pyobject * string) -> pyobject
Sourceval pydict_delitemstring : (pyobject * string) -> int
Sourceval pydict_setitemstring : (pyobject * string * pyobject) -> int
Sourceval pyint_fromlong : int64 -> pyobject
Sourceval pyint_aslong : pyobject -> int64
Sourceval pyint_getmax : unit -> int64
Sourceval pyfloat_fromdouble : float -> pyobject
Sourceval pyfloat_asdouble : pyobject -> float
Sourceval pymodule_new : string -> pyobject
Sourceval pymodule_getdict : pyobject -> pyobject
Sourceval pymodule_getname : pyobject -> string
Sourceval pymodule_getfilename : pyobject -> string
Sourceval pytuple_new : int -> pyobject
Sourceval pytuple_size : pyobject -> int
Sourceval pytuple_getitem : (pyobject * int) -> pyobject
Sourceval pytuple_setitem : (pyobject * int * pyobject) -> int
Sourceval pytuple_getslice : (pyobject * int * int) -> pyobject

py.ml: the result type has been changed from int to pyobject.

Sourceval pyslice_new : (pyobject * pyobject * pyobject) -> pyobject
Sourceval pyerr_setnone : pyobject -> unit
Sourceval pyerr_setobject : (pyobject * pyobject) -> unit
Sourceval pyerr_setstring : (pyobject * string) -> unit
Sourceval pyerr_occurred : unit -> pyobject
Sourceval pyerr_clear : unit -> unit
Sourceval pyerr_fetch : (pyobject * pyobject * pyobject) -> pyobject * pyobject * pyobject
Sourceval pyerr_givenexceptionmatches : (pyobject * pyobject) -> int
Sourceval pyerr_exceptionmatches : pyobject -> int
Sourceval pyerr_normalizeexception : (pyobject * pyobject * pyobject) -> pyobject * pyobject * pyobject
Sourceval pyclass_new : (pyobject * pyobject * pyobject) -> pyobject
Sourceval pyinstance_new : (pyobject * pyobject * pyobject) -> pyobject
Sourceval pyinstance_newraw : (pyobject * pyobject) -> pyobject
Sourceval pymethod_new : (pyobject * pyobject * pyobject) -> pyobject
Sourceval pymethod_function : pyobject -> pyobject
Sourceval pymethod_self : pyobject -> pyobject
Sourceval pymethod_class : pyobject -> pyobject
Sourceval pyimport_getmagicnumber : unit -> int64
Sourceval pyimport_execcodemodule : (pyobject * string) -> pyobject
Sourceval pyimport_execcodemoduleex : (string * pyobject * string) -> pyobject
Sourceval pyimport_getmoduledict : unit -> pyobject
Sourceval pyimport_addmodule : string -> pyobject
Sourceval pyimport_importmodule : string -> pyobject
Sourceval pyimport_importmoduleex : (string * pyobject * pyobject * pyobject) -> pyobject
Sourceval pyimport_import : pyobject -> pyobject
Sourceval pyimport_reloadmodule : pyobject -> pyobject
Sourceval pyimport_cleanup : unit -> unit
Sourceval pyimport_importfrozenmodule : string -> int
Sourceval pyeval_callobjectwithkeywords : (pyobject * pyobject * pyobject) -> pyobject
Sourceval pyeval_callobject : (pyobject * pyobject) -> pyobject
Sourceval pyeval_getbuiltins : unit -> pyobject
Sourceval pyeval_getglobals : unit -> pyobject
Sourceval pyeval_getlocals : unit -> pyobject
Sourceval pyeval_getrestricted : unit -> int
Sourceval pyobject_type : pyobject -> pyobject
Sourceval pyobject_size : pyobject -> int
Sourceval pyobject_getitem : (pyobject * pyobject) -> pyobject
Sourceval pyobject_setitem : (pyobject * pyobject * pyobject) -> int
Sourceval pyobject_delitem : (pyobject * pyobject) -> int
Sourceval pyobject_ascharbuffer : pyobject -> string
Sourceval pyobject_asreadbuffer : pyobject -> string
Sourceval pyobject_aswritebuffer : pyobject -> string
Sourceval pynumber_check : pyobject -> int
Sourceval pynumber_add : (pyobject * pyobject) -> pyobject
Sourceval pynumber_subtract : (pyobject * pyobject) -> pyobject
Sourceval pynumber_multiply : (pyobject * pyobject) -> pyobject
Sourceval pynumber_truedivide : (pyobject * pyobject) -> pyobject
Sourceval pynumber_floordivide : (pyobject * pyobject) -> pyobject
Sourceval pynumber_divide : (pyobject * pyobject) -> pyobject
Sourceval pynumber_remainder : (pyobject * pyobject) -> pyobject
Sourceval pynumber_divmod : (pyobject * pyobject) -> pyobject
Sourceval pynumber_power : (pyobject * pyobject * pyobject) -> pyobject
Sourceval pynumber_negative : pyobject -> pyobject
Sourceval pynumber_positive : pyobject -> pyobject
Sourceval pynumber_absolute : pyobject -> pyobject
Sourceval pynumber_invert : pyobject -> pyobject
Sourceval pynumber_lshift : (pyobject * pyobject) -> pyobject
Sourceval pynumber_rshift : (pyobject * pyobject) -> pyobject
Sourceval pynumber_and : (pyobject * pyobject) -> pyobject
Sourceval pynumber_xor : (pyobject * pyobject) -> pyobject
Sourceval pynumber_or : (pyobject * pyobject) -> pyobject
Sourceval pynumber_int : pyobject -> pyobject
Sourceval pynumber_long : pyobject -> pyobject
Sourceval pynumber_float : pyobject -> pyobject
Sourceval pynumber_inplaceadd : (pyobject * pyobject) -> pyobject
Sourceval pynumber_inplacesubtract : (pyobject * pyobject) -> pyobject
Sourceval pynumber_inplacemultiply : (pyobject * pyobject) -> pyobject
Sourceval pynumber_inplacetruedivide : (pyobject * pyobject) -> pyobject
Sourceval pynumber_inplacefloordivide : (pyobject * pyobject) -> pyobject
Sourceval pynumber_inplacedivide : (pyobject * pyobject) -> pyobject
Sourceval pynumber_inplaceremainder : (pyobject * pyobject) -> pyobject
Sourceval pynumber_inplacelshift : (pyobject * pyobject) -> pyobject
Sourceval pynumber_inplacershift : (pyobject * pyobject) -> pyobject
Sourceval pynumber_inplaceand : (pyobject * pyobject) -> pyobject
Sourceval pynumber_inplacexor : (pyobject * pyobject) -> pyobject
Sourceval pynumber_inplaceor : (pyobject * pyobject) -> pyobject
Sourceval pynumber_inplacepower : (pyobject * pyobject * pyobject) -> pyobject
Sourceval pysequence_check : pyobject -> int
Sourceval pysequence_size : pyobject -> int
Sourceval pysequence_length : pyobject -> int
Sourceval pysequence_concat : (pyobject * pyobject) -> pyobject
Sourceval pysequence_repeat : (pyobject * int) -> pyobject
Sourceval pysequence_getitem : (pyobject * int) -> pyobject

py.ml: the result type has been changed from int to pyobject.

Sourceval pysequence_getslice : (pyobject * int * int) -> pyobject
Sourceval pysequence_setitem : (pyobject * int * pyobject) -> int
Sourceval pysequence_delitem : (pyobject * int) -> int

py.ml: one of the two pyobject arguments has been removed.

Sourceval pysequence_setslice : (pyobject * int * int * pyobject) -> int
Sourceval pysequence_delslice : (pyobject * int * int) -> int
Sourceval pysequence_tuple : pyobject -> pyobject
Sourceval pysequence_list : pyobject -> pyobject
Sourceval pysequence_fast : (pyobject * string) -> pyobject
Sourceval pysequence_count : (pyobject * pyobject) -> int
Sourceval pysequence_contains : (pyobject * pyobject) -> int
Sourceval pysequence_in : (pyobject * pyobject) -> int
Sourceval pysequence_index : (pyobject * pyobject) -> int
Sourceval pysequence_inplaceconcat : (pyobject * pyobject) -> pyobject
Sourceval pysequence_inplacerepeat : (pyobject * int) -> pyobject
Sourceval pymapping_check : pyobject -> int
Sourceval pymapping_size : pyobject -> int
Sourceval pymapping_length : pyobject -> int
Sourceval pymapping_haskeystring : (pyobject * string) -> int
Sourceval pymapping_haskey : (pyobject * pyobject) -> int
Sourceval pymapping_getitemstring : (pyobject * string) -> pyobject
Sourceval pymapping_setitemstring : (pyobject * string * pyobject) -> int
Sourceval pyiter_check : pyobject -> int
Sourceval pyiter_next : pyobject -> pyobject
Sourceval pynull : unit -> pyobject
Sourceval pynone : unit -> pyobject
Sourceval pytuple_fromarray : pyobject array -> pyobject
Sourceval pytuple_fromsingle : pyobject -> pyobject
Sourceval pytuple_empty : pyobject
Sourceval pytuple2 : (pyobject * pyobject) -> pyobject
Sourceval pytuple3 : (pyobject * pyobject * pyobject) -> pyobject
Sourceval pyint_fromint : int -> pyobject
Sourceval pyint_asint : pyobject -> int
Sourceval pytuple_toarray : pyobject -> pyobject array
Sourceval pywrap_closure : (pyobject -> pyobject) -> pyobject
OCaml

Innovation. Community. Security.