Skip to content

Tree lenses #30

Description

@cfhammill

I find data.tree cumbersome because of mutation. I want a library free of this inconvenience, but it does a lot of nice things I would miss. Convenient print methods, easy data.frame conversion, automatic ancestry/depth tracking. I am torn between writing lenses for data.tree and writing a simpler tree library built around a lens API. Provided I write simple conversions between the two we could potentially have the best of both worlds.

Writing lenses for data.tree would involve checking to see if the lens is pointing at a node, following the node's ancestry to the tree root, and triggering a full copy on set. It is possible I'm over-estimating the performance problems associated with this. R triggers full list copies on modify too, although I suspect R is making very smart choices about copying/GC that make it dramatically faster than copying data.trees (although I should really test).

Hacking a tree API seems easier to me than optimizing copy speed or decreasing copy frequency in data.tree but involves writing a lot more code.

Decisions, decisions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions