Are reference cycles bad form?
Steven Taschuk
staschuk at telusplanet.net
Sun Apr 20 05:30:38 EDT 2003
Quoth Manuel M Garcia:
> On Sat, 19 Apr 2003 11:16:10 -0600, Steven Taschuk
> <staschuk at telusplanet.net> wrote:
>
> >Imho this is an engineering question, not a style question. [...]
>
> In my current case, it feels more like a style question, instead of an
> engineering question. [...performance and memory use are irrelevant...]
Ah. So you're optimizing for clarity (rather than, say,
performance); that is indeed a matter of style.
Imho structures with reference cycles are not intrinsically more
or less clear than structures without, so as a general principle
they are neither good form nor bad form. (In a particular case,
of course, their presence might enable a clearer algorithm or
simplify other aspects of the data structure; in such cases they
are good form, though only indirectly.)
In other words, don't worry about using reference cycles qua using
reference cycles; only worry about them insofar as they affect the
clarity of other things.
[...]
> Happily, Python code is easy to refactor, so I am more likely in
> Python to experiment with different data structures and algorithms,
> and pick the one that feels 'cleanest'.
Just so!
--
Steven Taschuk staschuk at telusplanet.net
"Telekinesis would be worth patenting." -- James Gleick
More information about the Python-list
mailing list