This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author yselivanov
Recipients asvetlov, brett.cannon, larry, ncoghlan, yselivanov
Date 2015-05-20.00:55:27
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1432083329.36.0.116064786395.issue23889@psf.upfronthosting.co.za>
In-reply-to
Content
After some experiments, it looks like bind() is already pretty fast. The only way to increase its performance is to rewrite it in C.

I tried to approaches:

1. Refactor ._bind() to produce a high-level instruction set that can be cached, and is fast to iterate through and build BoundArguments.  Repo: https://github.com/1st1/cpython/tree/bind

Results:

====================================  ===========  ==============  ===============
function / call                       bind (3.4)   bind cache hit  bind cache miss
====================================  ===========  ==============  ===============
() / ()                               0.716s       0.746s  (-4%)   0.799s  (-10%)
(a, b=1) / (10)                       1.140s       0.910s  (+20%)  1.294s  (-12%)
(a, b=1, *ar) / (10, 20, 30, 40)      1.352s       1.145s  (+15%)  1.520s  (-11%)
(a, b=1, **ar) / (10, 20, z=30, y=4)  1.364s       1.233s  (+10%)  1.660s  (-18%)
(a, b=1, *, z, **ar) / (1,2,z=3,y=4)  1.499s       1.363s  (+10%)  1.897s  (-26%)


2. Refactor ._bind() to compile a function that builds BoundArguments for te given args/kwargs shape.  This approach yields more-or-less same results as (1), but performance of cache-miss case is just terrible (-200%).  Compiling functions on the fly is expensive.  Repo to play with: https://github.com/1st1/cpython/tree/bind_jit


I'm closing this issue, until I (or someone else) can implement bind() in C (or come up with a faster pure-python implementation).
History
Date User Action Args
2015-05-20 00:55:29yselivanovsetrecipients: + yselivanov, brett.cannon, ncoghlan, larry, asvetlov
2015-05-20 00:55:29yselivanovsetmessageid: <1432083329.36.0.116064786395.issue23889@psf.upfronthosting.co.za>
2015-05-20 00:55:29yselivanovlinkissue23889 messages
2015-05-20 00:55:28yselivanovcreate