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

Maciej Fijalkowski fijall at gmail.com
Thu Sep 29 12:14:02 CEST 2011


On Thu, Sep 29, 2011 at 5:51 AM, Armin Rigo <arigo at tunes.org> wrote:
> 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
> value.
>
> Try with a test like this:
>
> def f(n):
>   is_constant(n)
> def g(n):
>   f(5)
>   f(n)
>
>
> A bientôt,
>
> Armin.
> _______________________________________________
> pypy-dev mailing list
> pypy-dev at python.org
> http://mail.python.org/mailman/listinfo/pypy-dev
>

It works (maybe should be documented so) because you have a
specialization on the constantness of function arg.


More information about the pypy-dev mailing list