Hello,Rpy
2009/12/19 Olli Wang <[email protected]>
>
> Hi, I tried to convert a list to tuple in RPython such as tuple([1, 2, 3]),
> but it would cause errors during translating.
> Is that a bug? I did find theĀ builtin_tuple() function
> inĀ http://codespeak.net/pypy/dist/pypy/annotation/builtin.py,
> so it should work, right?

A RPython tuple is very different from a list. Please see
http://codespeak.net/pypy/dist/pypy/doc/coding-guide.html#object-restrictions
For me, a RPython tuple is similar to the python's
collection.namedtuple object: the fields (number and types) are fixed,
and if you can access items by their position in the tuple, the index
value must be known at translation time (for type inference to
succeed).
It is very similar to the C++ boost::tuple template class.

Yet another reason why it would be difficult to rewrite the python
standard library in RPython...

--
Amaury Forgeot d'Arc
_______________________________________________
[email protected]
http://codespeak.net/mailman/listinfo/pypy-dev

Reply via email to