Couldn't you just write the loop in Python?

On May 12, 2015 9:42:47 PM CDT, Yicong Huang <hengha....@gmail.com> wrote:
>Hi,
>
>I read the document "Embedding Pypy". It introduces the method to call
>pypy
>function from C.
>In our scenaro, we would like to call the same pypy function from C for
>thousands of times or even millions of times.
>Following the document, the code is like this:
>
> for(i = 0; i < count; i++){
>        res = pypy_execute_source(pyBuffer);
>        if(res)
>           break;
> }
> if (res || i < count) {
>       printf("Error calling pypy_execute_source!\n");
>  }
>
>However, the code is quite slow for reasons:
>1. Pypy treats the same function call for a new function every time. It
>took time to do parsing, analysing and such a lot of work.
>2. JIT could not give any benifits for the single function call.
>
>For looping 100,000 times in C code, it took about 1120.2 secondes.
>However, the same function executing in pypy for 100,000 times only
>cost
>about 3.7 secodes.
>
>Do we have any ideas to improve this case?
>For example, could we expose the function pointer in pypy to C, so that
>C
>code is able to call the same pypy function in the loop?
>
>Thanks!
>
>-Ethan
>
>
>------------------------------------------------------------------------
>
>_______________________________________________
>pypy-dev mailing list
>pypy-dev@python.org
>https://mail.python.org/mailman/listinfo/pypy-dev

-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.
_______________________________________________
pypy-dev mailing list
pypy-dev@python.org
https://mail.python.org/mailman/listinfo/pypy-dev

Reply via email to