bigint <-> python long

Ellery Newcomer ellery-newcomer at utulsa.edu
Thu Sep 6 12:59:27 PDT 2012


On 09/06/2012 04:11 AM, bearophile wrote:
> Ellery Newcomer:
>
>>> array.array <==> D arrays
>>
>> just checked, looks like we have it:
>>
>> PyStmts(q"{from array import array; a = array('i', [44,33,22,11]);}",
>> "testing");
>> assert(PyEval!(int[])("a", "testing") == [44,33,22,11]);
>>
>> I think if the python object is iterable, it can be converted to array.
>
> array.array are special, they aren't Python lists. array.array contains
> uniform data, so conversion to D arrays is a memcpy (or it's nearly
> nothing if you don't copy the data).
>
> Bye,
> bearophile

I see. The docs for array.array suggest that it implements the buffer 
interface, but it doesn't seem to implement new or old style buffers, at 
least according to PyObject_CheckBuffer and PyBuffer_Check.

I think I'll add support for new style buffers anyways. a memoryview 
would be good, too.

Guess I'll hack together a special case for array using buffer_info.


More information about the Digitalmars-d-learn mailing list