[pypy-dev] Arrays in rpython

Santhosh Edukulla santhosh.edukulla at gmail.com
Tue Jun 7 17:53:52 CEST 2011


Actually, there is also a module by name "Array"

import array

t=array.array(I,size)

Here t is a list and constrained more as an integer array.

Check docs for more help.

Thx.
Santhosh

On 6/7/11, Maciej Fijalkowski <fijall at gmail.com> wrote:
> On Mon, Jun 6, 2011 at 8:54 PM, Timothy Baldridge <tbaldridge at gmail.com>
> wrote:
>>> In case you don't already know: in Python (and RPython), lists are
>>> implemented as
>>> resizeable arrays, i.e. they look more like a C++ std::vector and not
>>> a std::list.
>>>
>>> This said, IIRC RPython has special code for fixed-size lists.
>>> I think you just have to avoid all resizing functions.
>>> This means that the list must be created with statements like
>>>    array_of_ints = [0] * 32
>>>    array_of_objects = [None] * 32
>>
>>
>> Excellent! Exactly what I was looking for. Thanks.
>>
>> Timothy
>>
>
> There is also pypy.rlib.debug.make_sure_not_resized which would make
> annotation explode if you by chance resize this list.
> _______________________________________________
> pypy-dev mailing list
> pypy-dev at python.org
> http://mail.python.org/mailman/listinfo/pypy-dev
>


More information about the pypy-dev mailing list