[pypy-dev] SmallTuples

William ML Leslie william.leslie.ttg at gmail.com
Thu May 26 10:59:15 CEST 2011


On 26 May 2011 16:00, Amaury Forgeot d'Arc <amauryfa at gmail.com> wrote:
> 2011/5/26 William ML Leslie <william.leslie.ttg at gmail.com>:
>> The python tuple is intended to be a heterogeneous data structure, as
>> they are in RPython. The length of a tuple is conceptually part of the
>> type, which means that tuple length will be static in sane code
>> anyway.
>
> But does this apply to the *args tuple?

Good point - you mean "sometimes, frequently not".

In the context we are considering, namely promotion of tuple length
for small tuples, I want to pretend the answer is yes.  It means that
we get call-site specialisation for heterogeneous usage, and ignore it
for most homogeneous usage.  Heterogeneous *args usage is probably
common enough - for example, in wrapping decorators, it is common to
accept and pass *args and **kwargs to the wrapped function, and if the
length of the tuple were promoted, the pack and unpack could be
simplified.

I suspect that limiting the discussion to /small/ tuples will take
care of the outliers, but benchmarks are a good idea.

-- 
William Leslie


More information about the pypy-dev mailing list