Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid creating most slice objects #972

Merged
merged 2 commits into from
Oct 16, 2015
Merged

Avoid creating most slice objects #972

merged 2 commits into from
Oct 16, 2015

Conversation

kmod
Copy link
Collaborator

@kmod kmod commented Oct 16, 2015

We've been allocating slice objects for slicing operations, but
CPython's internal slice methods already take separate start+stop
arguments. So if we see a slice, instead of creating the slice
and sending it off to getitem, try calling PySequence_GetSlice.

This will be slower for classes with user-defined getitem
functions that can handle slices; we can fix that by adding rewriting
to this new endpoint, but it seems to not matter too much right now.

           django_template3.py             2.4s (4)             2.4s (4)  +0.5%
                 pyxl_bench.py             2.1s (2)             2.1s (2)  +0.8%
     sqlalchemy_imperative2.py             2.5s (2)             2.5s (2)  -0.3%
       django_template3_10x.py            14.8s (2)            14.8s (2)  +0.2%
             pyxl_bench_10x.py            15.7s (2)            15.1s (2)  -3.6%
 sqlalchemy_imperative2_10x.py            18.7s (2)            18.5s (2)  -0.9%
                       geomean                 6.2s                 6.1s  -0.6%

@kmod kmod force-pushed the avoid_slices branch 3 times, most recently from 8a81917 to 1fc0d1c Compare October 16, 2015 07:37
@undingen
Copy link
Contributor

lgtm

We've been allocating slice objects for slicing operations, but
CPython's internal slice methods already take separate start+stop
arguments.  So if we see a slice, instead of creating the slice
and sending it off to getitem, try calling PySequence_GetSlice.

This will be slower for classes with user-defined __getitem__
functions that can handle slices; we can fix that by adding rewriting
to this new endpoint, but it seems to not matter too much right now.
@kmod
Copy link
Collaborator Author

kmod commented Oct 16, 2015

thanks for taking a look :)

kmod added a commit that referenced this pull request Oct 16, 2015
Avoid creating most slice objects
@kmod kmod merged commit c380bbc into pyston:master Oct 16, 2015
@kmod kmod deleted the avoid_slices branch November 3, 2015 20:23
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