[PySide] Is del in python completely equivalent to delete in c for Qt objects?
ijbrewster at alaska.edu
Thu Feb 6 22:19:24 CET 2020
Thank you. That was very informative and helpful.
Alaska Volcano Observatory
Geophysical Institute - UAF
2156 Koyukuk Drive
Fairbanks AK 99775-7320
> On Feb 6, 2020, at 12:00 PM, John Ehresman <jpe at wingware.com> wrote:
> On 2/7/20 9:41 AM, Israel Brewster wrote:
>> On Feb 6, 2020, at 11:28 AM, John Ehresman <jpe at wingware.com <mailto:jpe at wingware.com>> wrote:
>>> In general, del in Python is very different than delete in C++. I'll leave it to others to explain.
>> In general, sure. In general, python memory management is very different than C/C++ memory management, so it stands to reason that del/delete would, in general, be different as well. I’m not asking about the general case, I’m asking about the Qt case, and the things that Qt does when you delete a Qt object. I’m not asking for a low-level view of memory management. I’m asking if the *behavior*, as far as *Qt* objects is concerned, is the same.
> With PyQt or PySide, C++ delete is called when the last Python reference is dropped to an object created from Python (there are other conditions as well). Python del will drop a reference to the object so C++ delete will be invoked if there are no other references to the object (and other conditions are met). In my experience, relying on this is a mistake because there are often other references in all but the simplest examples.
>>> or PySide may expose a function to do a C++ delete -- it's probably shiboken.delete().
>> That sounds like what I’m looking for, assuming that a python del doesn’t do the same thing.
> If you want to be sure C++ delete is called, I recommend that you use the function to call it.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the PySide