I am working on a project where I am happy with the vector package and wish to optimize it as much a possible without affecting the other packages that make up the project. I am aware that I can use the following inside a defun to optimize that single function
(declare (optimize (speed 3) (safety 0)))
and also that 'declaim' could be used to make the effect global.
Is there a way to optimize everything in a package or is it just safer to declare in each function?
[EDIT] Just a heads up to future readers: In almost all cases you do not want to use safety 0. Research this topic further before ever setting this in your code as you are opening yourself up to very system & implementation dependent bugs if you muck it up
The extent of declaim is implementation dependent. In SBCL I think you may use with-compilation-unit to achieve what you want. However, I doubt the utility of this for performance purpose: most of the time performance critical code is concentrated on a very few places, and whatever gain you may have from the rest of the code is not worth the sacrifices of safety and debuggability.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With