Commit 1425819
committed
Refine the implementation of cached_method
Thanks to feedback from @jaraco, this adjustment makes the public
interface for `cached_method` a function which is responsible for the
argument management, rather than trying to use `__call__` on the
descriptor itself.
This frees up `__call__` to lookup the relevant LRU-cached function and
invoke it, which makes the `_cached_method` descriptor suitable for use
as a `property.fget` callable.
Tests are updated to indicate that a decorator can be prepared and then
used repeatedly (which was previously an explicit error), and can be used
under a property decorator.1 parent a5b4b0d commit 1425819
2 files changed
Lines changed: 45 additions & 30 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1202 | 1202 | | |
1203 | 1203 | | |
1204 | 1204 | | |
1205 | | - | |
| 1205 | + | |
1206 | 1206 | | |
1207 | 1207 | | |
1208 | 1208 | | |
| |||
1215 | 1215 | | |
1216 | 1216 | | |
1217 | 1217 | | |
1218 | | - | |
1219 | | - | |
1220 | | - | |
1221 | | - | |
| 1218 | + | |
1222 | 1219 | | |
1223 | 1220 | | |
1224 | 1221 | | |
1225 | 1222 | | |
1226 | | - | |
1227 | | - | |
1228 | | - | |
| 1223 | + | |
| 1224 | + | |
1229 | 1225 | | |
1230 | | - | |
1231 | | - | |
1232 | | - | |
1233 | | - | |
1234 | | - | |
1235 | 1226 | | |
1236 | 1227 | | |
1237 | | - | |
| 1228 | + | |
| 1229 | + | |
| 1230 | + | |
| 1231 | + | |
1238 | 1232 | | |
1239 | 1233 | | |
| 1234 | + | |
| 1235 | + | |
| 1236 | + | |
| 1237 | + | |
| 1238 | + | |
1240 | 1239 | | |
1241 | 1240 | | |
1242 | 1241 | | |
1243 | 1242 | | |
1244 | | - | |
1245 | | - | |
1246 | | - | |
1247 | 1243 | | |
1248 | 1244 | | |
1249 | 1245 | | |
| |||
1269 | 1265 | | |
1270 | 1266 | | |
1271 | 1267 | | |
| 1268 | + | |
| 1269 | + | |
| 1270 | + | |
| 1271 | + | |
| 1272 | + | |
| 1273 | + | |
| 1274 | + | |
| 1275 | + | |
| 1276 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3843 | 3843 | | |
3844 | 3844 | | |
3845 | 3845 | | |
3846 | | - | |
3847 | | - | |
3848 | | - | |
3849 | | - | |
3850 | | - | |
3851 | | - | |
| 3846 | + | |
| 3847 | + | |
3852 | 3848 | | |
3853 | | - | |
3854 | | - | |
3855 | | - | |
3856 | | - | |
| 3849 | + | |
| 3850 | + | |
| 3851 | + | |
| 3852 | + | |
| 3853 | + | |
| 3854 | + | |
| 3855 | + | |
| 3856 | + | |
| 3857 | + | |
| 3858 | + | |
| 3859 | + | |
| 3860 | + | |
| 3861 | + | |
| 3862 | + | |
| 3863 | + | |
| 3864 | + | |
| 3865 | + | |
| 3866 | + | |
| 3867 | + | |
3857 | 3868 | | |
3858 | | - | |
3859 | | - | |
3860 | | - | |
| 3869 | + | |
| 3870 | + | |
3861 | 3871 | | |
3862 | 3872 | | |
3863 | 3873 | | |
| |||
0 commit comments