On Sat, Aug 27, 2011 at 1:21 PM, "Martin v. Löwis" <martin@v.loewis.de> wrote:
> I'd like to better understand why ctypes is (sometimes) frowned upon.
>
> Is it the brittleness?  Tendency to segfault?

That, and Python should work completely if ctypes is not available.

What are the most major platforms ctypes doesn't work on?

It seems like there should be some way of coming up with an xml file describing the types of the various bits of data and formal arguments - perhaps using gccxml or something like it.

> FWIW, I have a partial implementation of a module that does xz from
> Python using ctypes.

So does it work on Sparc/Solaris? On OpenBSD? On ARM-Linux? Does it
work if the xz library is installed into /opt/sfw/xz?

So far, I've only tried it on a couple of Linuxes and Cygwin.  I intend to try it on a large number of *ix variants in the future, including OS/X and Haiku.  I doubt I'll test OpenBSD, but I'm likely to test on FreeBSD and Dragonfly again.

With regard to /opt/sfw/xz, if ctypes.util.find_library(library) is smart enough to look there, then yes, xz_mod should find libxz there.

On Cygwin, ctypes.util.find_library() wasn't smart enough to find a Cygwin DLL, so I coded around that.  But it finds the library OK on the Linuxes I've tried so far.

(This is part of a larger project, a backup program.  The backup program has been tested on a large number of OS's, but I've not done another broad round of testing yet since adding the ctypes+xz code)