[Haskell-cafe] Re: [Haskell] ANNOUNCE: CPython / libpython bindings

Yitzchak Gale gale at sefer.org
Mon Dec 28 06:52:55 EST 2009

John Millikin wrote:
>>> ...Python language, has a C API...
>>> The cpython[2] package is a binding to this API.

I wrote:
>> How does this package compare to the classic MissingPy package?

> MissingPy appears to be a set of data types which implement MissingH
> classes using the Python library.

Not exactly. John Goerzen's MissingH and MissingPy libraries together
do provide some useful things that are (or were in the past) missing from
Haskell. Useful things that already exist in Python and would be a lot
of work to re-implement in Haskell are provided in MissingPy via the
Haskell binding to the Python API. The rest of the useful things are
provided as native Haskell implementations in MissingH.

But for me, and probably many others, the most important service
provided by MissingPy is the Python API binding itself.

> It has only a minimal binding to libpython, enough to implement
> its class instances but not enough for general-purpose use of
> libpython.

I'm not sure what you mean by that. Using MissingPy, you can
instantiate a Python object of any type, marshall data back and
forth between Python and Haskell for the basic built-in Python
types and any object built out of them, access any Python
module, and call any Python function or method. Most people
find those capabilities to be quite good for general-purpose use.
What do you feel is missing?

> I wrote this package so I could benchmark Python modules using
> Criterion, with an eye towards writing extension modules in Haskell,
> so it has many more data types and computations available.

Oh, you want to write Python extension modules in Haskell?
Right, MissingPy explicitly does not cover calling Haskell
from Python.

For accessing Python from Haskell, though, MissingPy has
been around for a long time and works well. There may be
quite a lot of code around that uses it. Is your API similar?
Is there any specific new capability that you are adding?
Do you have some compatibility recommendations?

One thing you certainly are adding is a more recent version
of Python - MissingPy is still at Python 2.5. Also, it is a
small annoyance that to use MissingPy's API binding you
also have to pull in all of the "missing" things from MissingH
and MissingPy and their dependencies. Those aren't used
as much these days now that there is so much available
from hackage.


More information about the Haskell-Cafe mailing list