64-bit / 128-bit data element type for array?

Robert Kern robert.kern at gmail.com
Mon Dec 22 18:21:23 EST 2008


akineko wrote:
> Hello Robert,
> 
>> Is that actually a 2s-complement 128-bit unsigned integer, or is it just a
>> 128-bit-long chunk of data?
> 
> That is a good question.
> A 128-bit data can be anything.
> A 128-bit data can be an instrution code (VLIW machines use such wide
> instruction). A 128-bit can be a packed ascill (16 chrs).
> A 128-bit can be a descriptor (a structure of various fields).
> It is probably safe to say that only unsigned 128-bit is required.
> (I cannot think of any situations where signed 128-bit is necessary)

Ah, good. numpy lets you construct your own data types from the primitives. 
Since you don't actually need uint128 arithmetic, you don't need a uint128 
primitive. You can just use dtype('V16') (meaning "void, 16 bytes long") for the 
"anything" and "instruction codes" and possible as an intermediate format. 
Byteswapping will work just fine. Use can use dtype('S16') for the ASCII. If the 
structure can be described by bytes, then the structured dtypes will work just 
fine. Unfortunately, we don't support bit-fields.

If you need bit-field support, you may want to take a look at Construct. 
Actually, you may want to look at Construct anyways.

   http://construct.wikispaces.com/

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
  that is made terrible by our own mad attempt to interpret it as though it had
  an underlying truth."
   -- Umberto Eco




More information about the Python-list mailing list