Skip to content

Conversation

kmod
Copy link
Collaborator

@kmod kmod commented Jul 17, 2015

Not super common, but can seems to help since we are particularly bad at handling a in (b, c).

       django_template.py             3.6s (2)             3.6s (2)  -0.5%
            pyxl_bench.py             3.5s (2)             3.5s (2)  -0.4%
sqlalchemy_imperative2.py             4.3s (2)             4.3s (2)  -0.9%
                  geomean                 3.8s                 3.8s  -0.6%

Do this by adding "contains" to our codegen type system, and
implement a special contains on the unboxedtuple type.

This makes this operation quite a lot faster, but it looks like
largely because we don't implement a couple optimizations that
we should:
- we create a new tuple object every time we hit that line
- our generic contains code goes through compare(), which returns
  a box (since "<" and friends can return non-bools), but contains
  will always return a bool, so we have a bunch of extra boxing/unboxing

We probably should separate out the contains logic from the rest of the
comparisons, since it works quite differently and doesn't
gain anything by being there.
@tjhance
Copy link
Contributor

tjhance commented Jul 17, 2015

I haven't looked too closely at your diff but the transformation in your subject line is incorrect, e.g.,

>>> n = float('nan')
>>> n in (n,n)
True
>>> n == n or n == n
False

@kmod
Copy link
Collaborator Author

kmod commented Jul 17, 2015

oh doh that's true

kmod added a commit that referenced this pull request Jul 17, 2015
Convert "a in (b, c)" to "a == b or a == c"
@kmod kmod merged commit 65712e0 into pyston:master Jul 17, 2015
@kmod kmod deleted the perf4 branch July 17, 2015 01:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants