Re: [pypy-dev] pypy callback function pointer become invalid

2015-08-18 Thread Yicong Huang
Great thanks Armin! The method should work. And I thought "exec", "compiled" and "cached" together do the quite similar work as pypy_execute_source() does. Yes, in theory we could do all these work by ourselves, and also could be more flexible to chose what need to do and what need not to do. But I

Re: [pypy-dev] pypy callback function pointer become invalid

2015-08-17 Thread Armin Rigo
Hi, On 17 August 2015 at 12:59, Yicong Huang wrote: > However, to perform the python function call, we need to parse char*(python > code), a python code lexer, praser, JIT and etc, in other words do all the > work that pypy_execute_source() did. This is done in a couple of lines in Python. The

Re: [pypy-dev] pypy callback function pointer become invalid

2015-08-17 Thread Yicong Huang
Hi Armin, Great thanks for the demo code! I think the approach should work, but there might be a lot of work to do in "run_function" to perform a simple python function call. Assuming we would like to do the simple work as original pypy_execute_source_ptr() does, with such approch, we need to pass

Re: [pypy-dev] pypy callback function pointer become invalid

2015-08-17 Thread Armin Rigo
Hi Yicong, On 17 August 2015 at 08:40, Yicong Huang wrote: > yes, we could use a structure to wrap severl python callback function > pointers in one execution. > However, the issue is that we might not be able to get all python functions > that would be executed at the beginning. The basic idea

Re: [pypy-dev] pypy callback function pointer become invalid

2015-08-16 Thread Yicong Huang
The problem is there is *only one* entry python program. >From the document example ( http://pypy.readthedocs.org/en/latest/embedding.html#more-complete-example), yes, we could use a structure to wrap severl python callback function pointers in one execution. However, the issue is that we might not

Re: [pypy-dev] pypy callback function pointer become invalid

2015-08-16 Thread Maciej Fijalkowski
Think about the API that way: there is only one "entry" python program that you run and you can still execute arbitrary code. On Sun, Aug 16, 2015 at 10:01 AM, Eric Driggers wrote: > Agreed, have been doing basically that for some internal code, as the > docs kind of hint: > > http://pypy.readthe

Re: [pypy-dev] pypy callback function pointer become invalid

2015-08-16 Thread Eric Driggers
Agreed, have been doing basically that for some internal code, as the docs kind of hint: http://pypy.readthedocs.org/en/latest/embedding.html#more-complete-example Basically call the pypy_execute_source_ptr() once, passing in a API struct to fill out for low-level call-backs. (And passing in at t

Re: [pypy-dev] pypy callback function pointer become invalid

2015-08-16 Thread Maciej Fijalkowski
On Sun, Aug 16, 2015 at 6:12 AM, Yicong Huang wrote: > Thanks for reminding! > I looked at the code, and observed the gloal new dict might leak memory. > > Calling pypy_execute_source_ptr() multiple times might be a common usage: > you might have several python files to execute, or you might get p

Re: [pypy-dev] pypy callback function pointer become invalid

2015-08-15 Thread Yicong Huang
Thanks for reminding! I looked at the code, and observed the gloal new dict might leak memory. Calling pypy_execute_source_ptr() multiple times might be a common usage: you might have several python files to execute, or you might get python code segment from input one by one ... I am thinking coul

Re: [pypy-dev] pypy callback function pointer become invalid

2015-08-15 Thread Maciej Fijalkowski
On Sat, Aug 15, 2015 at 4:09 PM, Armin Rigo wrote: > Hi Yicong, > > On 11 August 2015 at 14:38, Yicong Huang wrote: >>pypy_execute_source_ptr(pyBuffer, &ptr); > > The documentation recommends to call pypy_execute_source_ptr() only > once. I've fixed anyway the particular problem you are

Re: [pypy-dev] pypy callback function pointer become invalid

2015-08-15 Thread Armin Rigo
Hi Yicong, On 11 August 2015 at 14:38, Yicong Huang wrote: >pypy_execute_source_ptr(pyBuffer, &ptr); The documentation recommends to call pypy_execute_source_ptr() only once. I've fixed anyway the particular problem you are encountering when calling it multiple times, in 20f74886a28e.