[Python-Dev] Python-Dev Digest, Vol 125, Issue 5

Fil Mackay fil at pobox.com
Fri Dec 6 02:31:07 CET 2013

Hi Antoine,

> I've found that libffi does support this type, but sadly ctypes and cffi
> do
> > not. Adding to ctypes does not seem to be trivial, since the description
> of
> > an integer type is limited to a single character ("q" in the case of long
> > long). "q" is considered to be a length of 8, whereas what I really want
> is
> > the integer type "ll" which is correctly considered length of 16.
> Aren't you talking about the struct module? In ctypes, it seems it
> would be sufficient to add a "c_int128" type (and/or "c_uint128").

Adding a c_int128 type seems somewhat non trivial though. The
specific-sized c_intX types are assigned to the named equivalents (c_long
etc.). Getting a named type that equates to 128-bit (on OSX at least
anyway) is the problem.

The :

class c_something(_SimpleCData):
    _type_ = "?"

The type "q" seems to relate to "long long" ("q"uad word?) - but that has a
size of 8 for me. I don't know: what "something" should be, and what "?"
should be.

I am guessing stay away from the "long long long" schenanigans and just
define c_int128 directly:

class c_int128(_SimpleCData):
    _type_ = "?"

.. but there still seems to lack a _type_ that will relate to a 128-bit

OK, it seems that adding a new "?" that relates to 128-bit requires the
change to struct module. This seems to be in lib-dynload and is written in
C not python?

> Can anyone give me some pointers as to why this has not been added to
> date,
> > and the best line of attack?
> Probably because noone needed it until now?
> We have a comprehensive guide if you want to contribute a patch:
> http://docs.python.org/devguide/
> The first step would be to open an enhancement request on the
> issue tracker, the discussion will then move on there:
> http://bugs.python.org/

> (if you want to enhance both the ctypes and struct modules, please open
> a separate issue for each)

OK, thanks. I had been put off by the "bugs" title since this is an
enhancement.. will do.

Regards, Fil.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20131206/319be03f/attachment.html>

More information about the Python-Dev mailing list