[Python-Dev] adding Construct to the standard library? (original) (raw)

Travis E. Oliphant oliphant.travis at ieee.org
Tue Apr 25 07:41:41 CEST 2006


Greg Ewing wrote:

Travis Oliphant wrote:

For what it's worth, NumPy also defines a data-type object which it uses to describe the fundamental data-type of an array. In the context of this thread it is also yet another way to describe a binary-packed structure in Python. Maybe there should be a separate module providing a data-packing facility that ctypes, NumPy, etc. can all use (perhaps with their own domain-specific extensions to it). It does seem rather silly to have about 3 or 4 different incompatible ways to do almost exactly the same thing (struct, ctypes, NumPy and now Construct).

I agree. Especially with ctypes and struct now in the standard library. The problem, however, is that every module does something a little-bit different with the object. NumPy needs a built-in object with at least a few fields defined.

The idea of "specifying the data-type" is different then it's representation to NumPy.

After looking at it, I'm not particularly fond of Construct's way to specify data-types, but then again we've been developing the array interface for just this purpose and so have some biased opinions.

Some kind of data-type specification would indeed be useful. NumPy needs a built-in (i.e. written in C) data-type object internally. If that builtin object were suitable generally then all the better.

For details, look at http://numeric.scipy.org/array_interface (in particular the array_descr field of the interface for what we came up with last year over several months of discussion.

-Travis



More information about the Python-Dev mailing list