Login and get codingGiven the sample class
Planet, computing themassattribute of an instance is a computationally expensive and time consuming operation. Ideally you'd like this attribute to be acached_propertythat only gets computed once and is then stored for future access, not having to be recalculated over (and over and over).
Tasks
Complete
cached_property(func)as a decorator function, so that asking "What was the mass ofPlanet('red')again?" is consistent and quick.Note: Attempting to set
massshould raiseAttributeErroras it is read-only.Hint: replace the
@propertydecorator with your implementation of@cached_propertyand remove the mass setter entirely, attempting to setmassshould raiseAttributeErroras it is read-only.
              
                147 out of 147 users completed this Bite.
              
              
                Will you be the 148th person to crack this Bite?
              
              
                Resolution time: ~53 min. (avg. submissions of 5-240 min.)
                
                
              
              
                Our community rates this Bite 6.64 on a 1-10 difficulty scale.
                
                  
                    » Up for a challenge? 💪