Replace cached_property
with property
or functools_property
#2660
Labels
feature request
New feature request
cached_property
with property
or functools_property
#2660
Summary
cached_property
is often unnecessary and can be replaced withproperty
orfunctools.cached_property
(if some criteria are met)What is the feature request for?
The core library
The Problem
The goal of
cached_property
is to prevent from recalculating compute (intensive) code when the result is not expected to change. However, it is used all over the place in the library without any scope. It does not cache any compute intensive code, and at best, makes it arguably less memory efficient. Also, it causes typing and documentation rendering issues.The Ideal Solution
The solution would be to do the following for every usage of
utils.cached_property
:property
__dict__
in__slots__
(see here why, altough it should never be the case as pycord usescached_slot_property
, but is good to mention), repalce it withfunctools.cached_property
.With the goal of utlimately entirely removing
cached_property
.The Current Solution
n/a
Additional Context
property
instead ofNewType(...)
to fix type annotations for ApplicationContext attributes #2636pycord/discord/commands/context.py
Line 223 in 61cc544
pycord/discord/commands/context.py
Line 167 in 61cc544
The text was updated successfully, but these errors were encountered: