Skip to content

What is the mechanism that makes exported model faster than python code without modelx? #99

Answered by fumitoh
bakerwy asked this question in Q&A
Discussion options

You must be logged in to vote

That's because the exported model uses caching (a.k.a. memoization) mechanism. For example, when foo(100) is called for the first time in the exported model, the returned value of foo(100) is remembered. Then, when foo(100) is called the next time, the saved value is returned. In the pure-Python model, foo(100) is calculated every time it's called. You can achieve a similar effect by writing functions with @cache from the functools standard library.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@bakerwy
Comment options

Answer selected by bakerwy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants