Hi,

2011/6/6 Timothy Baldridge <[email protected]>:
> Is there a way in rpython to specify that a given list should be
> implemented as an array? I want to create a list of objects exactly 32
> entries long. I could use [] but it seems like that would be slower
> than using an array. In CPython I can create an array of primitive
> types, but I'm looking to create a array of object types.

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

-- 
Amaury Forgeot d'Arc
_______________________________________________
pypy-dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-dev

Reply via email to