3 ms·
When is it a good idea to use @property? It's tempting to apply to almost every 0-ary method, even if it computes something expensive that isn't not worth memoi
by jey 13y ago
When is it a good idea to use @property? It's tempting to apply to almost every 0-ary method, even if it computes something expensive that isn't not worth memoizing and tying to self's lifetime.
- GuiA 13y agoIf it is a 0-ary method AND does not mutate the state of its instance.
- benjamincburns 13y ago... and if it's not likely to cause performance issues.
- Ysx 13y agoAnd if you're not going to leak an AttributeError from any code in your method, else hasattr will return False.