Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork3.1k
[mypyc] Allow specifying primitives as pure#17263
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Pure primitives have no side effects, take only immutable arguments,and never fail. These properties will enable additionaloptimizations. For example, it doesn't matter in which orderthese primitives are evaluated, and we can perform commonsubexpression elimination on them.Only mark a few primitivies as pure for now, but we can generalizethis later.
dmadisetti commentedJun 3, 2024
Is there a timeline / roadmap for pure function detection? Or is this more exploratory? |
JukkaL commentedJun 4, 2024
This is specific to primitives, i.e. it isn't used for user-defined functions. Since there is a closed set of primitives, it wouldn't be hard to manually annotate all of them that are pure. There are no plans currently to automatically detect if user-defined functions are pure, if that's what you are interested in. |
Pure primitives have no side effects, take only immutable arguments,
and never fail. These properties will enable additional
optimizations. For example, it doesn't matter in which order
these primitives are evaluated, and we can perform common
subexpression elimination on them.
Only mark a few primitives as pure for now, but we can generalize
this later.