extending python with array functions

Janwillem jwevdijk at xs4all.nl
Tue Feb 5 14:57:16 EST 2008


Gabriel Genellina wrote:
> En Tue, 05 Feb 2008 05:28:33 -0200, Marc 'BlackJack' Rintsch 
> <bj_666 at gmx.net> escribi�:
> 
>> On Mon, 04 Feb 2008 20:56:02 -0200, Gabriel Genellina wrote:
>>
>>> - the array module http://docs.python.org/lib/module-array.html provides
>>> homogeneuos arrays that may be more efficient for your application. 
>>> arrays
>>> don't have a special API, you have to import the module and use its
>>> functions the same as one would do in pure Python.
>>
>> There's one special thing about it: the `buffer_info()` method returns a
>> tuple with the memory address and length (in items) of the current
>> underlying buffer. Pretty useless information in Python but handy in
>> extensions that can directly access the "raw" memory.
> 
> Good to know! I didn't notice it the (only) time I had to use arrays 
> from C code.
> 
Thanks for the advice. I think I will read the cstype stuff because it 
might mean that my calculation intensive functions (non-linear systems 
and Monte Carlo stuff) can be kept unchanged ans stay compatible with 
e.g. the Excel interfaces I have for them. My first attempt with 
sum(i,j) was successful but sum(x,y) (FORTRAN typecast thinking) needs 
apparently understanding ctypes.
Janwillem



More information about the Python-list mailing list