does python have useless destructors?

Roger Binns rogerb at rogerbinns.com
Mon Jun 14 01:38:51 CEST 2004


Martin v. Löwis wrote:
> So in short: you are not proposing an implementable
> solution.

Actually I did.  I am not saying this is not a hard
problem.  It *is* a hard problem.  It is also a very real
problem as we have seen handled in various ways in
various languages.

But at one point generating code for algorithms was hard,
and then compilers were invented.  And memory management
was hard and GC was invented.  Storage was hard and
filesystems were invented.

The whole point of languages is to make stuff easier.
And Python excels at letting the machine deal with
machine issues.  None of the tens of thousands of lines
of Python code I have written even knows what byte
ordering a machine uses, or even its natural word
size.

So here is a hard problem.  Feel free to prove that it
is insoluable (in the computer science sense), or lets
pick a solution that improves things.

As a programmer I would be very happy to get an exception
or similar diagnostic if I create a case that Python
can't currently cope with.  I can change my code to fix
it.  But making every consumer of every resource including
indirectly deal with something the machine should figure
out is silly.  They used to do that once about memory
and fortunately those days are behind us.

And if you want an example of how complex this can get,
try and modify the XML-RPC stuff to work over SSL and
due multiple requests/responses per connection.  There
are several layers of libraries and external resources
involved, and currently a lot of code written by very
smart people that tries real hard, has to implement
its own reference counting in Python, and doesn't work
over SSL or handle more than one request per connection.

Roger





More information about the Python-list mailing list