Commit 2f3c1e2
authored
Optimize cached_method when wrapping no-arg methods (#6381)
Previously, the first time a no-arg cached method was called the
decorator would make three calls: `hasattr`, `object.__setattr__`,
`getattr`, and when called subsequently it would make two calls:
`hasattr`, `getattr`. Here we refactor the implementation to use a
sentinel value so that on the first call we only make two calls:
`getattr`, `object.__setattr__`, and when called subsequently we only
make a single `getattr` call.1 parent ec727ca commit 2f3c1e2
1 file changed
+9
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
70 | 74 | | |
71 | 75 | | |
72 | 76 | | |
| |||
103 | 107 | | |
104 | 108 | | |
105 | 109 | | |
106 | | - | |
107 | | - | |
108 | | - | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
109 | 115 | | |
110 | 116 | | |
111 | 117 | | |
| |||
0 commit comments