Skip to content

KeyDict usage slow #726

Description

@whoburg

ConstraintSet.varkeys is slow. This affects Model.__getitem__. Is there any way we could store Model._varkeys and have a boolean flag that gets set by other methods when the varkeys need to be recomputed? Otherwise, I end up storing the varkeys and then accessing those instead of the model, to prevent multiple calls to varkey.

Timing example from a model with only ~400 variables:

In [18]: t = time.time(); (M["C_L"], M["C_D"]); print time.time() - t
2.10050082207

In [19]: t = time.time(); mvk = M.varkeys; (mvk["C_L"], mvk["C_D"]); print time.time() - t
1.06283092499

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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