[Tutor] destructor methods
Sean 'Shaleh' Perry
shalehperry@home.com
Fri, 30 Nov 2001 10:19:25 -0800 (PST)
On 30-Nov-2001 Timothy Wilson wrote:
> On Sat, 1 Dec 2001, Andrew Wilkins wrote:
>
>> When defining a class, you can define a method called __del__ to handle what
>> happens in the deletion, so it has the desired effect. Look for more in
>> "3.3.1 Basic Customisation" in the Python Reference Manual.
>
> So is there a performance benefit to explicitly calling __del__?
>
you actually say:
del var
this forces the variable to be garbage collected. Whether it needs a
destructor depends on how it was created.
It is safe to write the program without explicit del's the first time then go
through and see if optimization is needed.