Re: [pypy-dev] [pypy-commit] pypy default: Unroll list.count() when the list is virtual or very small and constant lenght

Hi Alex, please revert this change, it can lead to combinatorial explosion: it can give a bridge per pattern of where in the list the object is found. Cheers, Carl Friedrich On 29/08/13 23:47, alex_gaynor wrote:

On 30/08/13 12:58, Amaury Forgeot d'Arc wrote:
It looks like this: count = 0 i = 0 while i < self.length(): if space.eq_w(self.getitem(i), w_value): count += 1 i += 1 So there's a guard_true/false for every item. Note that even changing to: count += space.eq_w(self.getitem(i), w_value) does not fix this, because the guard is coming from inside space.istrue, or space.eq Cheers, Carl Friedrich

Hi Carl, I wonder if there's some sub-set of cases we can still unroll in. The particular code this was for is: https://bitbucket.org/pypy/pypy/src/default/lib-python/2.7/uuid.py#cl-130 . I wonder if there are cases where the list is both virtual *and* we aren't able to constant fold some of the space.eq_w()? Alex On Fri, Aug 30, 2013 at 5:31 AM, Carl Friedrich Bolz <cfbolz@gmx.de> wrote:
-- "I disapprove of what you say, but I will defend to the death your right to say it." -- Evelyn Beatrice Hall (summarizing Voltaire) "The people's good is the highest law." -- Cicero GPG Key fingerprint: 125F 5C67 DFE9 4084

On 30/08/13 15:09, Alex Gaynor wrote:
This is a completely indirect and way too clever way to express what is meant. I have absolutely no pity for this code being slow. Let's rewrite it to simply be more explicit, even if it's a few lines longer.
I wonder if there are cases where the list is both virtual *and* we aren't able to constant fold some of the space.eq_w()?
Yes, there can be, it's easy to write. Even the uuid case has the combinatorial problem, it's just that we expect people to not pass in random combinations of arguments. Cheers, Carl Friedrich

Fixing the code is fine with me, does someone want to help get that patch upstream into CPython so we don't have to worry about losing our modifications when we upgrade the stdlib? Alex On Fri, Aug 30, 2013 at 9:47 AM, Carl Friedrich Bolz <cfbolz@gmx.de> wrote:
-- "I disapprove of what you say, but I will defend to the death your right to say it." -- Evelyn Beatrice Hall (summarizing Voltaire) "The people's good is the highest law." -- Cicero GPG Key fingerprint: 125F 5C67 DFE9 4084

On 30/08/13 12:58, Amaury Forgeot d'Arc wrote:
It looks like this: count = 0 i = 0 while i < self.length(): if space.eq_w(self.getitem(i), w_value): count += 1 i += 1 So there's a guard_true/false for every item. Note that even changing to: count += space.eq_w(self.getitem(i), w_value) does not fix this, because the guard is coming from inside space.istrue, or space.eq Cheers, Carl Friedrich

Hi Carl, I wonder if there's some sub-set of cases we can still unroll in. The particular code this was for is: https://bitbucket.org/pypy/pypy/src/default/lib-python/2.7/uuid.py#cl-130 . I wonder if there are cases where the list is both virtual *and* we aren't able to constant fold some of the space.eq_w()? Alex On Fri, Aug 30, 2013 at 5:31 AM, Carl Friedrich Bolz <cfbolz@gmx.de> wrote:
-- "I disapprove of what you say, but I will defend to the death your right to say it." -- Evelyn Beatrice Hall (summarizing Voltaire) "The people's good is the highest law." -- Cicero GPG Key fingerprint: 125F 5C67 DFE9 4084

On 30/08/13 15:09, Alex Gaynor wrote:
This is a completely indirect and way too clever way to express what is meant. I have absolutely no pity for this code being slow. Let's rewrite it to simply be more explicit, even if it's a few lines longer.
I wonder if there are cases where the list is both virtual *and* we aren't able to constant fold some of the space.eq_w()?
Yes, there can be, it's easy to write. Even the uuid case has the combinatorial problem, it's just that we expect people to not pass in random combinations of arguments. Cheers, Carl Friedrich

Fixing the code is fine with me, does someone want to help get that patch upstream into CPython so we don't have to worry about losing our modifications when we upgrade the stdlib? Alex On Fri, Aug 30, 2013 at 9:47 AM, Carl Friedrich Bolz <cfbolz@gmx.de> wrote:
-- "I disapprove of what you say, but I will defend to the death your right to say it." -- Evelyn Beatrice Hall (summarizing Voltaire) "The people's good is the highest law." -- Cicero GPG Key fingerprint: 125F 5C67 DFE9 4084
participants (3)
-
Alex Gaynor
-
Amaury Forgeot d'Arc
-
Carl Friedrich Bolz