Skip to content

heap.Cycle.describe prints arrows that are not the reference direction #55

Description

@tamnd

pyxray.heap.cycles() returns the members of each strongly connected component in the order Tarjan's algorithm finished them in. Cycle.describe() then joins them with -> and closes the loop, which reads as a route through the cycle.

It is not a route. For a plain ring of three the two usually agree, but the order is a property of the search rather than of the references, and for a component containing more than one cycle there is no single route to print at all.

T09 works around this in prose by telling the reader to treat the output as a membership list. That is honest and slightly unsatisfying, since the arrows are right there suggesting otherwise.

Two ways out. Either find an actual path through the component before printing, walking gc.get_referents from one member and taking the first edge that stays inside the group, which gives a real route for the common single loop case and can fall back to the current behaviour otherwise. Or drop the arrows and print the members as a set, which is accurate and less useful to look at.

The first one is better if the fallback is honest about being a fallback. Worth doing before another lesson leans on this output.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/memoryobmalloc, reference counting and the cycle collectorkind/toolingpyxray, bpc, the widgets and the checkerspriority/p2Wanted, not scheduled

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions