3 ms·
Before going down this path, it's important to understand the substantial performance implications.
by puredanger 8y ago
Before going down this path, it's important to understand the substantial performance implications.
- lbj 8y agoIndeed
- jonstaab 8y agoChecks are turned off by default. Are there performance implications even when they're turned off? Reference: https://clojure.org/guides/spec https://clojure.org/guides/spec
- ambulancechaser 8y agospec is wholly independent of the pre/post conditions.
- aperiodic 8y agoIn this respect, they share the characteristic of being easy to wholly disable (i.e. prevent them from being compiled at all). With pre & post conditions if the var `clojure.core/assert` is bound to false, then they're elided. The usual pattern is to have them on for testing, and disable when compiling for production.
- puredanger 8y agoThe math functions are statically inlined for performance. Wrapping them in another level of function/var will have a significant impact on performance even if assertions for preconditions are turned off. Spec assertions (not pre/post checks) can actually be compiled completely out of production code so those can really be nothing (but not if you're adding them in wrapper layers).