Re: Calling python from C with OpenMP

2016-05-13 Thread Paul Rubin
Dennis Lee Bieber writes: > It's been tried -- but the non-GIL implementations tend to be > slower at everything else. Has Micropython been compared? CPython needs the GIL because of its frequent twiddling of reference counts. Without the GIL, multi-threaded CPython would have to acquire

Re: Calling python from C with OpenMP

2016-05-13 Thread Øystein Schønning-Johansen
On Friday, May 13, 2016 at 7:12:33 PM UTC+2, MRAB wrote: > Every PyGILState_Ensure call must be matched with a PyGILState_Release > call. The way it's currently written, it won't call PyGILState_Release > if ret is NULL. Yeah, that's tiny bug, however it is not the main problem... > However, I

Re: Calling python from C with OpenMP

2016-05-13 Thread MRAB
On 2016-05-13 17:22, Øystein Schønning-Johansen wrote: On Friday, May 13, 2016 at 2:04:53 AM UTC+2, Sturla Molden wrote: You must own the GIL before you can safely use the Python C API, object creation and refcounting in particular. Use the "Simplified GIL API" to grab the GIL and release it whe

Re: Calling python from C with OpenMP

2016-05-13 Thread Øystein Schønning-Johansen
On Friday, May 13, 2016 at 2:04:53 AM UTC+2, Sturla Molden wrote: > You must own the GIL before you can safely use the Python C API, object > creation and refcounting in particular. Use the "Simplified GIL API" to > grab the GIL and release it when you are done. I've now read about the GIL and it

Re: Calling python from C with OpenMP

2016-05-12 Thread Sturla Molden
wrote: > Second and most important question: When I run this code it sometimes > segementation faults, and sometimes some threads run normal and some > other threads says "Cannot call 'do_multiply'". Sometimes I get the > message: Fatal Python error: GC object already tracked. And some times it >

Calling python from C with OpenMP

2016-05-12 Thread oysteijo
Hi, I have a framework written in C and I need to call Python from that framework. I have written the code, and it runs fine, however when I recompile with OpenMP enabled, I get segmentation faults and some times an error message: Fatal Python error: GC object already tracked I'm able to reco

Re: calling python from C#...

2006-01-28 Thread Ravi Teja
Python for .NET http://www.zope.org/Members/Brian/PythonNet -- http://mail.python.org/mailman/listinfo/python-list

Re: calling python from C#...

2006-01-28 Thread Ravi Teja
I actually find Python for .NET most convenient http://www.zope.org/Members/Brian/PythonNet I did not try py2exe with these applications, so I cannot comment. -- http://mail.python.org/mailman/listinfo/python-list

Re: calling python from C#...

2006-01-23 Thread Jens Theisen
There is IronPython which compiles to .NET. And there was another project bridging the .NET runtime with the standard Python interpreter of which I forgot the name. Jens -- http://mail.python.org/mailman/listinfo/python-list

Re: calling python from C#...

2006-01-22 Thread Mr BigSmoke
I use python for .NET in some applications... I've always used it for using c# code from python (but i had some problems using it with py2exe and win2000). I'll try using it the other way (c# calling python). I also thought about trying ironpython, but it's too young for my work projects... The CO

Re: calling python from C#...

2006-01-22 Thread Ravi Teja
Writing COM Servers is not hard http://www.python.org/windows/win32com/QuickStartServerCom.html IronPython is the other way. Choose COM Server approach if you are using the a lot of standard library functions (as I recall IronPython is not complete here, yet). Definitely choose this approach if y

calling python from C#...

2006-01-22 Thread Mr BigSmoke
Hi everybody, I need write an application in c#, but i wnat to use some functions that i have already written in python. Is there an "easy" way to call my python code from c#? I must use COM or there are other ways? And, if COM is the only way, where can i find some tutorials or examples? I've neve

Re: segfault when calling Python from C thread

2005-02-21 Thread Greg Chapman
Fredrik Lundh wrote: > Greg Chapman wrote: > > > Your callback function needs to hold the Python GIL (and have a > > vaild threadstate) before it calls any Python C-API functions. > > Change the last part of it to: > > > >PyGILState_STATE state; > > > >/* ... */ > > > >/* Time to c

Re: segfault when calling Python from C thread

2005-02-20 Thread Fredrik Lundh
Greg Chapman wrote: > Your callback function needs to hold the Python GIL (and have a vaild > threadstate) before it calls any Python C-API functions. Change the > last part of it to: > >PyGILState_STATE state; > >/* ... */ > >/* Time to call the callback */ > >state = PyGILState_

Re: segfault when calling Python from C thread

2005-02-20 Thread Greg Chapman
Travis Berg wrote: > > I'm running into a problem when trying to perform a callback to a > Python function from a C extension. Specifically, the callback is > being made by a pthread that seems to cause the problem. If I call > the callback from the parent process, it works fine. The PyObject

segfault when calling Python from C thread

2005-02-19 Thread Travis Berg
I'm running into a problem when trying to perform a callback to a Python function from a C extension. Specifically, the callback is being made by a pthread that seems to cause the problem. If I call the callback from the parent process, it works fine. The PyObject is static, and holds the same