Re: Python C API: How to debug reference leak?

2016-09-27 Thread dl l
When I debug in C++, I see the reference count of a PyObject is 1. I don't know where is referencing this object. How can I find out where is referencing this object? 2016-09-27 15:47 GMT+08:00 dl l <ldlch...@gmail.com>: > Thanks for reply. Is there any function in C to get the referenc

Re: PyImport_AddModule vs PyImport_Import

2016-09-27 Thread dl l
Thanks. That's helpful. I did not notice the note. 2016-09-27 19:24 GMT+08:00 Ned Batchelder <n...@nedbatchelder.com>: > On Tuesday, September 27, 2016 at 3:54:01 AM UTC-4, dl l wrote: > > What is the difference between PyImport_AddModule and PyImport_Import? > >

PyImport_AddModule vs PyImport_Import

2016-09-27 Thread dl l
What is the difference between PyImport_AddModule and PyImport_Import? When need to use PyImport_AddModule? When need to use PyImport_Import? -- https://mail.python.org/mailman/listinfo/python-list

Re: Python C API: How to debug reference leak?

2016-09-27 Thread dl l
Thanks for reply. Is there any function in C to get the reference objects of a object? I want to debug where are referencing the object. 2016-09-27 15:01 GMT+08:00 dieter <die...@handshake.de>: > dl l <ldlch...@gmail.com> writes: > > I want to check the references of an o

Python C API: How to debug reference leak?

2016-09-26 Thread dl l
I want to check the references of an object. Any way to get the references of an object with Python C API? Like: gc.get_referrs(), is there similar API in C lib? -- https://mail.python.org/mailman/listinfo/python-list

Re: Python 3.5.1 C API, the global available available is not destroyed when delete the module

2016-09-21 Thread dl l
dieter <die...@handshake.de>: > dl l <ldlch...@gmail.com> writes: > > I found the problem is resolved if call PyGC_Collect() after > > PyDict_DelItemString(). Is it expected to call PyGC_Collect() here for > > Python 3.5 which is not needed for Python 3.3? > >

Re: Python 3.5.1 C API, the global available available is not destroyed when delete the module

2016-09-20 Thread dl l
20, 2016 at 4:19 PM, dl l <ldlch...@gmail.com> wrote: > > Yes, it's a workaround to set the global variables to None. But My app > just > > provide a framework for my customers to run python scripts. That's means > > the workaround requires my customers to update their py

Re: Python 3.5.1 C API, the global available available is not destroyed when delete the module

2016-09-20 Thread dl l
customers to update their python scripts. That may make them unhappy :(. Is there a workaround in my code C++ side to call Python C APIs to resolve the memory leak issue? 2016-09-20 13:49 GMT+08:00 Steven D'Aprano < steve+comp.lang.pyt...@pearwood.info>: > On Monday 19 September 2016 16:47, d

Re: Python 3.5.1 C API, the global available available is not destroyed when delete the module

2016-09-19 Thread dl l
Thanks for the replay. I run this script as __main__ module, this module is removed from sys.modules, and the ref count becomes 0. 2016-09-20 0:00 GMT+08:00 Chris Angelico <ros...@gmail.com>: > On Mon, Sep 19, 2016 at 4:47 PM, dl l <ldlch...@gmail.com> wrote: > > I have a

Python 3.5.1 C API, the global available available is not destroyed when delete the module

2016-09-19 Thread dl l
Hi, I have a app loading python35.dll. Use python API PyImport_AddModule to run a py file. And use PyDict_DelItemString to delete the module. There is a global vailable in the py file. The global variable is not destroyed when calling PyDict_DelItemString to delete the module. That cause the