On 3/4/18 6:55 PM, Ned Batchelder wrote:
On 3/4/18 5:25 PM, Ooomzay wrote:
On Sunday, 4 March 2018 14:37:30 UTC, Ned Batchelder wrote:
Are you including cyclic references in your assertion that CPython
behaves as you want?
Yes. Because the only behaviour required for RAII is to detect and
debug such cycles in order to eliminate them. It is a design
error/resource leak to create an orphan cycle containing RAII objects.
def main():
gc,disable
This isn't a reasonable position. Cycles exist, and the gc exists for
a reason. Your proposal isn't going to go anywhere if you just
naively ignore cycles.
--Ned.
While Ooomzay seems to want to say that all cycles are bad, I think it
is fair to say that in general in Python they are unavoidable, in part
because I can't see any good way to create the equivalent of a 'weak
reference' (names aren't objects so don't have properties). The best I
can think of is to create some sort of magical object that can refer to
another object, but that reference 'doesn't count'. This seems very
unPythonic.
What I think can be said is that it should be possible (enforced by the
programmer, not the language) to use these RAII objects in ways that
don't create cycles (or maybe that the program knows of the cycles and
makes the effort to break them when it is important). So perhaps it can
be said that cycle that involve major resource RAII objects should exist.
--
Richard Damon
--
https://mail.python.org/mailman/listinfo/python-list