Cached Properties Can Massively Speed Up Your Python Code
ฝัง
- เผยแพร่เมื่อ 1 พ.ย. 2023
- In this video we learn about cached properties, which can massively speed up parts of our Python code.
◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾
📚 Programming Books & Merch 📚
🐍 The Python Bible Book: www.neuralnine.com/books/
💻 The Algorithm Bible Book: www.neuralnine.com/books/
👕 Programming Merch: www.neuralnine.com/shop
💼 Services 💼
💻 Freelancing & Tutoring: www.neuralnine.com/services
🌐 Social Media & Contact 🌐
📱 Website: www.neuralnine.com/
📷 Instagram: / neuralnine
🐦 Twitter: / neuralnine
🤵 LinkedIn: / neuralnine
📁 GitHub: github.com/NeuralNine
🎙 Discord: / discord - วิทยาศาสตร์และเทคโนโลยี
A neat idea, I like it. I currently emplement the same principle by calculating the value once as it is set in a setter (basically in the init call to self.value = value, a setter is called that does the calculation) and then just access the result from a getter (property). What this allows me is to make sure that the value will be calculated even if someone attempts to change it afterwards, or curry the function and make sure that self.value = value can pass through the setter only once before it throws an error if the setter is called more than once. Overall, interesting idea from functools, but not really onboard, having to remember to delete the result and what not...
This seems like a good alternative to property setters that are only used on initialization
Very thankful to your python everyday tips🙏
Learnt something new today. Thanks
FIRST nice video!!!! good as always!
Basically it used for static function [Like static variables]
Thx_.
i am new, so i wanna ask, why we dont just to stored the data at variables? it's same thing as cached_property do
I have the same doubt. Why not store the result in a variable? I imagine the variable stays in memory and the cache in the cache file of python. But I could be wrong
Me three. It looks like the same solution, so why someone is just spending time on developing something that is already available...?
still need answer for this
sleep revistinha
useless.