Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Houdini: lsattr maybe use Houdini's own nodesearch #569

Open
BigRoy opened this issue Jan 26, 2022 · 0 comments
Open

Houdini: lsattr maybe use Houdini's own nodesearch #569

BigRoy opened this issue Jan 26, 2022 · 0 comments

Comments

@BigRoy
Copy link
Collaborator

BigRoy commented Jan 26, 2022

What happened?

The Houdini lsattrs logic does a search for nodes based on a parameter name and value which is used for host.ls() in Houdini.

I just heard of nodesearch that comes with Houdini out of the box. It might be worth actually relying on that logic instead.

It could make lsattrs basically like this:

# pseudocode match any of {attr: value} in attrs
import hou
import nodesearch

def lsattrs(attrs):
    root = hou.node("/obj")
    for attr, value in attrs.items():
        matcher = nodesearch.RawParm(attr, value, exact=True)
        for node in matcher.nodes(root, recursive=True)
            yield node

And I noticed the current logic in Houdini doesn't actually ensure all input values of the attrs dict get matched but if we do actually want that:

# pseudocode match all of {attr: value} in attrs
import hou
import nodesearch

def lsattrs(attrs):
    root = hou.node("/obj")
    matchers = []
    for attr, value in attrs.items():
        matchers.append(nodesearch.RawParm(attr, value, exact=True))
    for node in nodesearch.Group(matchers, intersect=True):
        yield node

It could be worth investigating whether the logic used by nodesearch is faster or not.

Additional Context

This could be a micro-optimization so might only really be worth if host.ls() really becomes problematic. But leaving it here for future reference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant