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
  • วิทยาศาสตร์และเทคโนโลยี

ความคิดเห็น • 14

  • @archardor3392
    @archardor3392 6 หลายเดือนก่อน +2

    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...

  • @goncaloazevedo9822
    @goncaloazevedo9822 6 หลายเดือนก่อน +1

    This seems like a good alternative to property setters that are only used on initialization

  • @yogimaharaj2587
    @yogimaharaj2587 6 หลายเดือนก่อน

    Very thankful to your python everyday tips🙏

  • @dev0cloo
    @dev0cloo 6 หลายเดือนก่อน

    Learnt something new today. Thanks

  • @sithican5706
    @sithican5706 6 หลายเดือนก่อน +1

    FIRST nice video!!!! good as always!

  • @hrithiksharma2047
    @hrithiksharma2047 6 หลายเดือนก่อน

    Basically it used for static function [Like static variables]

  • @philtoa334
    @philtoa334 6 หลายเดือนก่อน

    Thx_.

  • @AodaZamsee
    @AodaZamsee 6 หลายเดือนก่อน +1

    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

    • @nukedoom
      @nukedoom 6 หลายเดือนก่อน

      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

    • @LaNfinity
      @LaNfinity 6 หลายเดือนก่อน +1

      Me three. It looks like the same solution, so why someone is just spending time on developing something that is already available...?

    • @AodaZamsee
      @AodaZamsee 5 หลายเดือนก่อน

      still need answer for this

  • @jeanrodrigues6249
    @jeanrodrigues6249 6 หลายเดือนก่อน

    sleep revistinha

  • @goldy7695
    @goldy7695 6 หลายเดือนก่อน +2

    useless.