[pypy-dev] The builtin tuple() function doesn't work

Amaury Forgeot d'Arc amauryfa at gmail.com
Sat Dec 19 09:13:38 CET 2009


Hello,Rpy
2009/12/19 Olli Wang <olliwang at ollix.com>
>
> 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



More information about the Pypy-dev mailing list