[pypy-dev] [pypy-commit] pypy default: Merge a branch that makes space.isinstance(w_obj, <a constant>) do a fastpath

Armin Rigo arigo at tunes.org
Thu Sep 29 10:51:12 CEST 2011

Hi Maciek,

On Thu, Sep 29, 2011 at 10:33, Carl Friedrich Bolz <cfbolz at gmx.de> wrote:
>> +class Entry(ExtRegistryEntry):
>> +    _about_ = is_constant
>> +
>> +    def compute_result_annotation(self, s_arg):
>> +        from pypy.annotation import model
>> +        r = model.SomeBool()
>> +        r.const = s_arg.is_constant()
>> +        return r

This is wrong.  We tried at some point to have is_constant() but
failed.  The issue is that when calling is_constant(x), even if 'x'
turns out not to be constant in the end, it's possible that its
initial annotation says that it is a constant.  In this case, crash,
because you return "SomeBool(const=True)" and later
"SomeBool(const=False)", which is not a superset of the previous

Try with a test like this:

def f(n):
def g(n):

A bientôt,


More information about the pypy-dev mailing list