llvmlite
llvmlite copied to clipboard
Classes should use `__slots__` in order to reduce memory footprint.
Feature request
It would be fairly simple to add the __slots__
variable to most of or all the classes.
reasons to add __slots__
- reduces memory footprint of classes (biggest advantage imo)
- they are slightly faster
- helps with IDE type checkers
If you accept this idea, I can do it for you and make a pull request with the changes made.
Are you having memory or performance issues when using llvmlite? I'm concerned that adding __slots__
might break use cases where additional attributes are attached to instances, and add additional maintenance overhead.
Are you having memory or performance issues when using llvmlite? I'm concerned that adding
__slots__
might break use cases where additional attributes are attached to instances, and add additional maintenance overhead.
In terms of memory, yes, but I'm not 100% sure __slots__
would solve that, but it could help to reduce it. I found an old screenshot where I was trying to figure out why the memory usage in my app was so high. It turns out llvmlite.binding
is a 37mb
import, and running llvmlite.binding.create_mcjit_compile(...)
alone used 3.5mb
. Luckily I could remove that line since it turned out I didn't need it (I was following some tutorial article when first learning how to use llvmlite).
Edit: this doesnt seem to be llvmlite's fault here. I was misunderstanding the cause of the issue.