Skip to content

add a iter_project_parameters to make the related functions more efficient #2695

@sanzoghenzo

Description

@sanzoghenzo

Is your feature request related to a problem? Please describe

get_project_paramters returns a list of parameters, but the functions below that uses it only need an iterator to get the requested item.

https://github.com/pyrevitlabs/pyRevit/blob/develop/pyrevitlib/pyrevit/revit/db/query.py#L792-L858

Describe the solution you'd like

  • add a iter_project_parameters function with the content of the current get_project_parameters but with yield instead of the list generation
  • transform the get_project_partameters to return list(iter_project_parameters)
  • use iter_project_parameters in the functions below

Also, model_has_parameter doesn't really return a boolean, we should add a is not None at the end of the return line.

Additional context

There might be other situations like this in the code, no need to waste memory with lists to only get one (or some) item!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Good First IssueBug or feature with trivial solution that awaits you to be fixed!New FeatureNew feature request [class->Implemented #{number}: {title}]Python APIIssues related to pyrevit as a python module [subsystem]pythonPull requests that update Python code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions