Skip to content

Compile and evaluate separately #30

@markhats

Description

@markhats

I may be wrong, but it looks like when you call expression.evaluate({ x: 1 }), it compiles it into a JS function every time before evaluating. Is it possible to compile the expression just once and then call evaluate many times on the compiled function, passing in different values for x? This would make it much faster than compiling every time.

The equivalent math.js workflow would be:

const node = math.parse(expr)         // parse expression into a node tree
const code = node.compile()           // compile the node tree
const result = code.evaluate([scope]) // evaluate the code with an optional scope

where the final evaluate could be called multiple times without recompiling.

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