Skip to content

Implement __eq__ for fastcore.xml.FT for value-based comparison #682

@gsganden

Description

@gsganden

Currently, fastcore.xml.FT instances appear to compare by identity rather than value. This behavior can make tasks like testing more complex. For example, fastcore.xml.FT("a", ("b",)) == fastcore.xml.FT("a", ("b",)) comes out False, which requires workarounds such as custom comparison helpers in tests. Implementing an __eq__ method in FT that compares instances based on their tag, attrs, and children would simplify these scenarios by enabling direct, intuitive value-based equality.

This change will require adding a corresponding __hash__ method if these objects are intended to be hashable.

I'm willing to make a PR if desired.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions