You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Private functions are expensive because of frame switching. Allowing functions to be inlineable allows us to skip that overhead.
Specification
Add a decorator @inline which allows the user to force a function to be inlined. (In the future, the compiler could theoretically use heuristics to decide whether or not to inline a function but that is out of this scope). @inline is only compatible with @private functions. When the compiler sees that it should inline the code but with new variable names and so forth.
(Note: parameters should either not be writeable or pass-by-copy)
This is a good idea, to be fair: @fubuloubu Our private functions are efficient in certain cases where inline functions ones wouldn't be again. Also inline increases bytecode very quickly.
The cool thing about this is that the base for this functionality already occurs in sqrt ;)
cf. also #4478 which performs automatic inlining. so i'm not sure we actually need user-tunable inlines anymore -- we should wait 1-2 release cycles for user feedback.
Simple Summary
Allow functions to be inlined
Motivation
Private functions are expensive because of frame switching. Allowing functions to be inlineable allows us to skip that overhead.
Specification
Add a decorator
@inline
which allows the user to force a function to be inlined. (In the future, the compiler could theoretically use heuristics to decide whether or not to inline a function but that is out of this scope).@inline
is only compatible with@private
functions. When the compiler sees that it should inline the code but with new variable names and so forth.(Note: parameters should either not be writeable or pass-by-copy)
example:
should have roughly the same output as
Backwards Compatibility
No incompatibilities
Dependencies
No known dependencies
Copyright
Copyright and related rights waived via CC0
The text was updated successfully, but these errors were encountered: