[pypy-dev] SmallTuples

William ML Leslie william.leslie.ttg at gmail.com
Thu May 26 07:01:46 CEST 2011


On 26 May 2011 14:23, William ML Leslie <william.leslie.ttg at gmail.com> wrote:
> On 26 May 2011 14:15, Alex Gaynor <alex.gaynor at gmail.com> wrote:
>> Well, IMO the issue is you can end up with a ton of guard_class that are
>> more precise than you need, plus you have to manually specialize for each
>> length, whereas with the other approach you can just automatically apply it
>> to all tuples.
>
> With the class approach, you can store the length on the class, saving
> some space for each object.

Also possibly relevant:

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.  I don't think this is over-specialisation, because for
homogeneous usage of tuples we usually won't be talking about
SmallTuples.

I guess that it does have potential to blow up, and wonder if we
already have a system for deoptimising the truly polymorphic case.

-- 
William Leslie


More information about the pypy-dev mailing list