Skip to content

Remove args sorting from And and Or? #17087

@asmeurer

Description

@asmeurer

As you can see from #17066 (comment), the sorting in the And and Or constructor (from LatticeOp) can take up a significant amount of time when using large logic expressions.

We should see if we can remove it. The _hashable_content, which is used by __eq__, already uses the frozenset _args, so equality checking would work even if the args order is different. However, it will break any code that expects args to be ordered, or expects the current order, so I do not expect this to be an easy fix.

An important warning here, currently LatticeOp.args is cached. We should remove the cache when testing this. Otherwise the cache will make it so that equal objects always have the same args, and potential test failures will be hidden. The cache wouldn't be needed without sorting anyway. We could just set .args in the constructor.

This is related to #5954, but I think removing the ordering from Add/Mul will be much harder, as they are used everywhere. We should try doing it with the logic classes first, to see what are the issues that come up.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions